Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data written to flash on LPC11C24 gets corrupted #99

Closed
zyp opened this issue Aug 27, 2015 · 11 comments
Closed

Data written to flash on LPC11C24 gets corrupted #99

zyp opened this issue Aug 27, 2015 · 11 comments
Milestone

Comments

@zyp
Copy link
Contributor

zyp commented Aug 27, 2015

I'm getting started with LPC11C24 here, and flash writes seems to get corrupted.

(gdb) load
Loading section .vectors, size 0x130 lma 0x0
Loading section .init_array, size 0x4 lma 0x130
Loading section .text, size 0x1c0 lma 0x134
Loading section .data, size 0x4 lma 0x2f4
Start address 0x134, load size 760
Transfer rate: 3 KB/sec, 190 bytes/write.
(gdb) compare-sections 
Section .vectors, range 0x0 -- 0x130: MIS-MATCHED!
Section .init_array, range 0x130 -- 0x134: MIS-MATCHED!
Section .text, range 0x134 -- 0x2f4: MIS-MATCHED!
Section .data, range 0x2f4 -- 0x2f8: matched.
warning: One or more sections of the remote executable does not match the loaded file
(gdb) x/wx 0x130
0x130 <_init_array_start>:  0x42900093
(gdb) detach
Detached from remote process.
(gdb) x/wx 0x130
0x130 <_init_array_start>:  0x00000139

I'd expect .vectors to mismatch, due to the signature generation, but not the other sections. Since .init_array contains an invalid address, the processor hardfaults during startup code.

@gsmcmullin
Copy link
Contributor

This may have been broken by my refactoring of the LPC code. Can you check if you have the same problem with v1.6-rc0. I unfortunately don't have any LPC11C24 to test with.

@dlaw
Copy link
Contributor

dlaw commented Jun 21, 2016

The first 512 bytes of the address space are mapped to boot ROM by default. Once you write the SYSMEMREMAP register (address 0x40048000) to have a value of 2, those 512 bytes are mapped to flash and all sections will match. The LPC bootloader automatically does this upon detecting valid user code, but the bootloader cannot run while you are holding the chip in reset with a debugger. See section 3.5.1 of the manual. In gdb, you can set {int}0x40048000 = 2 to achieve the same result.

In summary, this is not a bug with the LPC refactoring.

@zyp
Copy link
Contributor Author

zyp commented Jun 22, 2016

That doesn't explain why my code were hardfaulting. When the bootloader is mapped in, it should run before anything gets to the entry point of my code.

Unfortunately I put the project I were evaluating LPC11C for on hold, so I never got around to retesting, and right now I'm on vacation so I won't be able to for a while either.

@esden
Copy link
Member

esden commented Feb 23, 2017

Is there a verdict on this issue?

@esden esden added this to the V1.6 release milestone Feb 23, 2017
@zyp
Copy link
Contributor Author

zyp commented Feb 23, 2017

Well, I never got back to that project, so I haven't concluded with anything.

@dlaw
Copy link
Contributor

dlaw commented Feb 23, 2017

I am currently developing for LPC824, LPC1549, and LPC11U68 with the Black Magic Probe, and I have not experienced this issue. I do observe section mismatches, as described in zyp's initial report, until the SYSMEMREMAP register is set.

@esden
Copy link
Member

esden commented Feb 23, 2017

Should the Black Magic Probe code set the remap register when flashing the firmware? Or would that have some other negative impact?

@dlaw
Copy link
Contributor

dlaw commented Feb 24, 2017

I think the choice of whether to set the remap register should be left to the user. I set it in my gdbinit file most of the time, but every once in a while I disable that in order to step through the ROM bootloader with the debugger. Note that the address of the register differs between different LPC product lines.

@esden
Copy link
Member

esden commented Feb 24, 2017

So I think we should include this in the wiki so that people can find it. I think this should be added at least to the FAQ section. Can you provide us with the needed line for .gdbinit and the exact chip you are using? The text should then probably include some information about how to find the register for a similar LPC chip if it does not work for the user.

@dlaw
Copy link
Contributor

dlaw commented Feb 24, 2017

For the LPC8xx/LPC11xx, the relevant lines are

set mem inaccessible-by-default off
set {int}0x40048000 = 2

The exact chip I'm using is the LPC824 and the name of the register in question is "SYSMEMREMAP".

@esden
Copy link
Member

esden commented Feb 24, 2017

Thank you! I have added an item to the FAQ. Feel free to improve the wiki. Thank you very much for the help and your contribution.

@esden esden closed this as completed Feb 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants