News:

Let's find out together what makes a PIC Tick!

Main Menu

28 pin SSOP Development board

Started by JonW, Oct 05, 2021, 04:45 PM

Previous topic - Next topic

top204

#20
https://sourceforge.net/projects/tinypicbootload/


As with all open source software, the code and the documentation and technical details are an absolute mess on the above site, and be careful with the advice given on it, but it does give some ideas. I created the K42 bootloader firmware a couple of years ago, before it was available on the site, but now others have also created asm code for them.

It suffers from, virtually, zero support for PIC24 and dsPIC devices, but I am creating my own firmware for the ones I am using.

John Lawton

For custom bootloaders I've used MG Digital Solutions, Mikael is very helpful.

For one project he made an SPI bootloader so I could update the firmware on several SPI connected daughterboards from a mainboard (that also had a bootloader). Very handy.

https://ds30loader.com/index.php/about

John


top204

#22
I'd rather write my own bootloaders, as I have done for the past 20 years, than purchase one. :-)

I started writing bootloaders back in 2001 for the first PIC microcontrollers that had programmable flash memory. i.e. PIC16F84 and PIC16F628 and PIC16F877 etc... For the devices that did not contain a UART, I created a software serial interface.

I first wrote the PC apps in C++, then I found that Delphi was a better language for visual PC applications, so all the bootloaders were in Delphi and simple to use. Decoding the HEX formats was my first task, then altering the procedure to identify HEX32 as well.

With the windows versions before, dreadful, windows 10, finding the friendly name of the USB attached was a simple task of scanning and reading a registry section, so the device attached could be automatically identified and opened. i.e. Amicus18. But windows 10 has destroyed that ability and altered the registry for some inexplicable reason!

The microcontroller code always follows the same mechanism, depending on the erase and write block size, and the SFR bits that need to be altered. So the serial interface receives identifiers, then address, then data etc... With a simple CRC sent back so the PC application knows that things are OK, and where in memory an error occurs.

I used the tiny bootloader for convenience because I did not have the time to create a Delphi app that would also auto find the USB device on Windows 10, and was going to get back into it eventually. The tiny bootloader PC application works, but its code is staggeringly bad!

Yasin

'Check registry serial Port list Start -----------------------------
    Dim typecode As Long
    Dim lngKeyHandle As Long
    Dim lngResult As Long
    Dim lngCurIdx As Long
    Dim ValueName As String * 256
    Dim ValueNameLen As Long
    Dim Value As String * 256
    Dim ValueLen As Long
   
    lngResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "HARDWARE\DEVICEMAP\SERIALCOMM", 0&, KEY_READ, lngKeyHandle)

    If lngResult <> ERROR_SUCCESS Then
        MsgBox ("Cannot open key")
        Exit Sub
    End If

    lngCurIdx = 0
    ValueNameLen = 256
    ValueLen = 256

    While RegEnumValue(lngKeyHandle, lngCurIdx, ByVal ValueName, ValueNameLen, 0&, typecode, ByVal Value, ValueLen) = ERROR_SUCCESS

        If typecode = REG_SZ Then
            ComSelectComboBox.AddItem Value
        End If

        lngCurIdx = lngCurIdx + 1
        ValueNameLen = 256
        ValueLen = 256

    Wend

    Call RegCloseKey(lngKeyHandle)
    'Check registry serial Port list End -------------------------------

If USB device means serial port, this is how I find it with VB. Maybe it'll be of use to someone.

JonW

Les what did you need to add to the piccode.ini file?

Cheers

Jon

top204

#25
$6F, C, 18F w/128KB flash & 1024B EEPROM, $20000, $400, 264, 128,

For the 18F27K42 device I was developing with, so the 64K version should be:

$6F, C, 18F w/64KB flash & 1024B EEPROM, $20000, $400, 264, 64,

That "piccodes.ini" file is an absolute mess isn't it? You can tell the bootloader has had very little thought put into it, and "zero" professionalism or quality. :-) Unfortunately, this is typical of open source, so beginners see rubbish like that as standard, and follow suit to also make dreadful code that is over complex and messy, with little thought put into it! :-( No wonder apprenticeships were scrapped, because if that is the standard quality now, no-one would pass their apprenticeship. :-)

John Lawton

I learnt the other day that in the UK an apprenticeship is a dodge to avoid paying the (proper) minimum wage. An apprentice (even at age 20) may initially be paid only £4.30 per hour. That's a great way to incentivise trainees.

top204

#27
But that is standard John. :-)

When I was serving my time in the late 1970s, early 1980s, I was paid the lowest wage, until I had served my time! The whole point of an apprenticeship is to learn a trade from people who know their job (in the real world) and take pride in their work, and then, hopefully, go on to make some more money elsewhere, so it was classed as an extension of college. But I did make a few bob with working outside of work time and repaired a few TVs on the side. :-) Then as soon as I served my time, I left the company and got a better job, but as a carpet fitter trainee. LOL. I had had enough of TVs and electronics 24 hours a day, so I needed a change for a few years, especially in the department store full of young lasses, when I was about 21 years old. ;-) Then I got back into electronics and computers for a living when I had had enough of that, and it stayed with me for the rest of my life. :-)

It was either that, or stay on the dole, or become a road sweeper. :-)

John Lawton

But surely as a carpet fitter a long career lay ahead of you?

But you wove a career in electronics instead.

Cue other carpet jokes.

John

top204

#29
We all make mistakes in our early life John. However, I made the mistake of continuing to make mistakes for the rest of my life. :-) I used to always treat life as a journey, where, "if you are happy doing what you do, then do it, otherwise, try something else and see what happens" :-) I was an optimist and never got bothered by real life situations. Until...... My brain injury happened, and that was something I can not be optimistic about and not bother worrying about. :-( It is now where, when I wake up in the morning, the nightmare begins "literally". :-(

But, we just have to get on with things as best we can, and "live", not just "exist".

I used to also fit carpets on an evening, after work, for people, every now and then, up until I moved down to Norfolk back in 2001. So Terry's teachings served me well, bless him. I used to get free trousers and shirts and a free lunch in the department store when I was a young-un, because I was "seeing", wink, wink, some of the lasses behind the counters. LOL. Oooohhhhh the good old days, when my young life was casual and worry free!

JonW

The whole project and Gui/ lack of documentation is a joke.  Seems alot of people use it too..  Latest source is not available as the person who has modified it is selling a version of it from what I can see. I think I will just create a new Gui. 

Nice bootloader in Positron though!  I managed to get hold of some 27K devices to boot.

My apprenticeship was same, working on Nuke Subs and paid basically nothing for a really tough week then defence cuts and 15,000 skilled men and women looking for work.  Decided to get out the town and learn RF/Microwave in the early  to mid 90's and never looked back since.  Was very lucky getting a Job designing Radios & transceivers for Midland Mobile Radio before Cell phones killed that industry and soon after got an even better one with the very early Cambridge crew that were just getting into STB and LNB's and have been doing it ever since.  Odd how life throws curveballs and always seems to impact the nice guys!

 


See_Mos

#31
Faced with a complicated board to repair, little information, a helicopter booked to take it back to the oil rig which was loosing tens of thousands of pounds an hour and me only getting a few pounds an hour I often thought how nice it would have been to be a road sweeper or stacking shelves in a supermarket!

John Lawton

In that situation I would have demanded a significant pay rise!
By the way did you fix it?

joesaliba

#33
I am astonished with the money they make these turnkey contractors, well, almost anyone that has nothing to do with electrics. Less hazards, less responsibility than an electrician or plant technician, and they get paid extremely well. I never did EUR30,000 a month profit. You get the idea.

See_Mos

#34
I nearly always came through apart from when having difficulty getting the required components.

Fortunately the majority of the work was much simpler and no deadlines to meet.  I was put under stress from time to time but rarely had to work late.

TimB


The reality is that workers never make money. You might make the company money but the boss will just use that to pay themselves high salaries.

I'm reasonable lucky in that my industry I charge a lot of money but since sales are sporadic you never make a lot.

The people who do well are the ones with the balls to say it costs x to design/build and I will charge 3 x that + 50%. I have yet to learnt that one.
These days my attitude has changed, rather than looking to make big £££. I work on, can I make enough to cover my bills and pay the 2 people who do work for me.  If so then I'm happy.

I do get wound up though. I'm working on a job that I really underpriced. Not going to lose money but not made enough to cover real time costs.



JonW

Hi Les

I tried the bootloader and it compiles ok and the bootloader program finds the device but when I upload a hex file it goes through all the sending but has an error at the end and nothing is written to the chip?

it stated the following after the hex dump

Uploading PROGMEM
Uploading program memory
   write mem pos: 0x00000000(byte)
      send: TBLPTRU=0x00, TBLPTRH=0x00, TBLPTRL=0x00, block=128
 80 EF FF F0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
      no answer
ERROR: Problem in uploading HEX file to device
Closed COM7 serial port
TinyMultiBootLoader+ completed

What needs to be added to the main program and the bootloader?

All I have done is programmed the bootloader as is into the device and on my program enabled LVP and added the declare bootloader = on

Is this correct?

Cheers

Jon

top204

In the PC program, make sure the device is being detected and is operating at the correct Baud rate.

I know the PC program is far too over-bloated, but click on the "Check-Device" button and make sure the correct line is being used for the reset of the microcontroller.

The Declare Bootloader is no longer required, and is a left-over from the very early compiler versions. The LVP will be ignored because the fuses are set by the bootloader's firmware, so changes to the final fuses will need to be set within the bootloader firmware itself. My advice is not to use the bootloader to overwrite the config fuses because one mistake and the whole device will be bricked until new bootloader firmware is loaded into it, so make sure the "program fuses" is unticked in the main PC app.

JonW

It definitely connects and detects the chip.  Just thought I needed to add a compiler start address etc to the user code

Jon

JonW

one other thing is that I had compiled the bootloader a few week ago with no problems but then installed the LangMF that Atomix had and after that the compiler complained about the $define being a non hex value??  I then de installed the LangMF and re-installed the compiler and your bootloader compiles again.  Very odd