mitxela / kiloboot

1kB TFTP Ethernet bootloader for ATmega328P and ENC28J60
52 stars 16 forks source link

jump to the main program #3

Closed vorohorio closed 4 years ago

vorohorio commented 4 years ago

Thanks for the useful project! I have a strange feature: after restart, the bootloader downloads program.bin from the tftp-server and flashes it. But the launch of the main program does not occur. I can start it only after deleting program.bin or stopping the tftp server. What am I doing wrong?

mitxela commented 4 years ago

Are you sure the program isn't running? Have you tried loading a much simpler program that just flashes an LED or something, just to check?

Have you looked at it in wireshark, and does it download the file just once or repeatedly?

Did you try reading out the memory of the chip afterwards to see if it had flashed correctly?

vorohorio commented 4 years ago

Thanks for the correct questions that led me to solve the problem. Of course, testing was carried out on a simple firmware with a blinking LED. The firmware loaded correctly and worked, after I changed the LED PIN to another. The problem turned out to be a side effect that the loader has on the main program. After jump control to main program the hardware SPI stays on, which prevents the use of the SPI pins (PB1-PB5) for other task. On my board, the PB5 was connected to the onboard LED, and it did not work after the bootloader. I added instructions to disable hardware SP at the beginning of the main program, and this solved the problem. Thanks.

mitxela commented 4 years ago

Ah yes, it doesn't reset the SPI, it's assumed the main program will be using the ethernet chip too and re-initialize that. Cheers.