vha3 / Hunter-Adams-RP2040-Demos

Demo code for the Raspberry Pi Pico
193 stars 54 forks source link

Hardfault on Serial Bootloader #5

Open jchatt0 opened 6 months ago

jchatt0 commented 6 months ago

I'm having a hard fault on the serial bootloader application.

Running the debugger, it seems to be OK with parsing the "bad checksum" data that the Python program sends initially. But as soon as it starts sending real data from the bootloader_blinky hex file, it goes into hard fault.

I've traced it down to the "transformLine" function, and there is something that it doesn't like about this code, but I don't know why: for (i=0; i<(char_count>>1); i++) { // Get the top nibble (careful of ASCII offsets) if (buffer[i<<1] < 'A') top = buffer[i<<1] - '0' ; else top = buffer[i<<1] - 'A' + 10 ;
// Get the bottom nibble (careful of ASCII offsets) if (buffer[(i<<1)+1] < 'A') bottom = buffer[(i<<1)+1] - '0' ; else bottom = buffer[(i<<1)+1] - 'A' + 10 ; // Mask the two nibbles into a byte buffer[i] = (top<<4) | bottom ;

I will keep digging.