ataradov / mcu-starter-projects

Simple starter projects for bare-metal MCU development
307 stars 41 forks source link

rp2040 UF2 file works well. But .elf or .hex is not working #7

Open MVinothPMS opened 1 year ago

MVinothPMS commented 1 year ago

Demo.UF2 is executing without any issues. But when I use Demo.elf, the program is not executing. I am able to load blink.elf(blink program from PICO SDK 1.5.0) successfully using picoprobe to target rp2040

ataradov commented 1 year ago

This project includes a boot sector that needs to have a valid CRC included. You have two options:

  1. Program a BIN file passed though this utility https://github.com/ataradov/tools/tree/master/bin2uf2
  2. Do this once and see what CRC is generated for your compiler setup and edit rp2040.ld and change the value in "LONG(0xcccccccc)" to a real CRC value. After that all ELF file will include a valid CRC. At least until you change the compiler version and it generates a different code.
MVinothPMS commented 1 year ago

Dear Alex,

Thank you for the quick response. I downloaded the utility and done 'Make' of bin2uf2.c and got the bin2uf2.exe

Followed by, I used the command .\bin2uf2 -i D:\TestProject\rp2040\bin2uf2\Demo.bin -o Demo1.uf2 -u

I printed the CRC value and converted it to hex LONG(0x88769055). Copied the value into rp2040.ld

Even then, the elf file is not getting executed. Whereas the UF2 file works well.

Regards, Vinoth M.


From: Alex Taradov @.> Sent: 29 July 2023 20:03 To: ataradov/mcu-starter-projects @.> Cc: Vinoth Magadevan @.>; Author @.> Subject: Re: [ataradov/mcu-starter-projects] rp2040 UF2 file works well. But .elf or .hex is not working (Issue #7)

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

This project includes a boot sector that needs to have a valid CRC included. You have two options:

  1. Program a BIN file passed though this utility https://github.com/ataradov/tools/tree/master/bin2uf2
  2. Do this once and see what CRC is generated for your compiler setup and edit rp2040.ld and change the value in "LONG(0xcccccccc)" to a real CRC value. After that all ELF file will include a valid CRC. At least until you change the compiler version and it generates a different code.

— Reply to this email directly, view it on GitHubhttps://github.com/ataradov/mcu-starter-projects/issues/7#issuecomment-1656743442, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BBS6OSC3P57SCLPYFOQJ4VDXSUNKFANCNFSM6AAAAAA24POM3U. You are receiving this because you authored the thread.Message ID: @.***>

ataradov commented 1 year ago

With "-u" option it would generate raw binary file, not UF2 file, so I'm not sure how it works for you.

Can you attach your binary file so I can check it on my side?

lakis70 commented 1 year ago

i have weact rp2040 with 16mb flash. The blink Demo.uf2 works. note: i add the flag -mfloat-abi=softfp because it made error sorry, unimplemented: Thumb-1 hard-float VFP ABI compiling with arm-none-eabi-gcc 10.2 and newlib 3.0. Thank you very much for your work

lakis70 commented 11 months ago

How do you initialize the ADC module? They say disable digital functions and make pin input. Is my code right?

`HAL_GPIO_PIN(ch0, 0, 26, null) ; //pin name, port, Gpio26, function ADC)
//pin33 analog ground

void init_ADC(void) { RESETS_CLR->RESET = RESETS_RESET_adc_Msk ; //reset

ADC->CS = ADC_CS_EN_Msk ; 
ADC->CS = ADC_CS_AINSEL_Msk ; //select Ch0 gpio26

HAL_GPIO_ch0_in() ; //set direction in
HAL_GPIO_ch0_pulldown(); //disable pull-up

} ` Thank you.

ataradov commented 11 months ago

I think digital functions are disabled by default on the ADC pins anyway, so just don't do anything.

Also, _pulldown() enables pull-down. There is currently no function to disable both, so don't enable any of them

For the ADC itself - I have no idea, never used it. But your two writes to CS are clearly not correct. The second write will overwrite the EN write.

lakis70 commented 11 months ago

i will try later and report. Thank you