EmbeddedRelated.com
Forums

Bootloader problems on LPC175x

Started by Tim Mitchell December 10, 2010
I am trying to create a bootloader on an LPC1754 using the IAP commands.

I have placed my bootloader code at 0x00000400 with the main code starting at 0x00002000. The bootloader cannot change any flash below 0x00002000.

I can get the flash to program and verify correctly, however when the device is restarted it doesn't run.
I think this may be something to do with the valid code signature in the exception vector table, though I am actually trying to reload the same program as was already in the chip, so any code signature should be the same, and I am not changing the area of memory at 0x0000 where the vector table is.
Another mystery - how does the vector table normally get programmed into the flash? I'm using Crossworks and programming by JTAG, which all works fine. If I generate a hex file for my bootloader, there is no code for 0x0000000, the exception vector location.
Any suggestions what I'm doing wrong?

--
Tim Mitchell

An Engineer's Guide to the LPC2100 Series

Hi Tim,

> I can get the flash to program and verify correctly, however when the
> device is restarted it doesn't run.
> I think this may be something to do with the valid code signature in
> the exception vector table, though I am actually trying to reload the
> same program as was already in the chip, so any code signature should
> be the same, and I am not changing the area of memory at 0x0000 where
> the vector table is.

Use the debugger to see where you are. After reloading, attach JTAG, Target
> Attach Debugger, then Debug > Break. You may well be executing in the
ROM.

What you *can* do is after reloading your program using your bootloader, you
can always attach and use Target > Verify. This will tell you if the
application you've loaded by the bootloader matches the app that would have
been loaded by CrossWorks.

> Another mystery - how does the vector table normally get programmed
> into the flash? I'm using Crossworks and programming by JTAG, which all
> works fine. If I generate a hex file for my bootloader, there is no
> code for 0x0000000, the exception vector location.

The CRC is computed by CrossScript as a post-link command, IIRC. You can
edit the script file, if you need to do something different.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore arriving Winter 2010! http://www.soldercore.com

OK, it's executing in the boot ROM, so presumably it is something to do with the valid user code checking.

If I verify by JTAG, it verifies OK, so I have definitely programmed correctly.

Looking at the map file it appears to be putting the vector table at 0x2000, which I've defined as the start of the user code. I don't understand why this will power up correctly when programmed by JTAG but not when programmed by my bootloader code.
--
Tim Mitchell
t...@sabretechnology.co.uk ~ http://www.sabretechnology.co.uk
Sabre Technology (Hull) Ltd, 3a Newlands Science Park, Hull
HU6 7TQ Registered in England and Wales no.3131504
t:01482 801003 f:01482 801078
Ah, my mistake, it doesn't power up correctly even when programmed by JTAG. I presume I have made some error in relocating the user code to 0x2000.

What's the best way to do a bootloader - would I be better just copying it into RAM and executing from RAM?
--
Tim Mitchell

My bootloader starts at 0x0000 with application code starting at
0x8000. Vector checksum needs to be at 0x0014.
On 12/10/2010 9:40 AM, Tim Mitchell wrote:
>
> Ah, my mistake, it doesn't power up correctly even when programmed by
> JTAG. I presume I have made some error in relocating the user code to
> 0x2000.
>
> What's the best way to do a bootloader - would I be better just
> copying it into RAM and executing from RAM?
>
> --
> Tim Mitchell
Hi Tim,

I think basically it's a question of taste.
We do it in this way because we even want to be able overwrite the
bootloader by "itself" and you can't write into the flash while you are
executing out of it.
So you minimum need to put the routines responsable for writing the data
into the flash into RAM (this is what we do on the application as the
application booted by the bootloader does write into specific sectors of
the flash as well).

Hope that helps.

Best regards
Herbert

Am 10.12.2010 15:40, schrieb Tim Mitchell:
> Ah, my mistake, it doesn't power up correctly even when programmed by JTAG. I presume I have made some error in relocating the user code to 0x2000.
>
> What's the best way to do a bootloader - would I be better just copying it into RAM and executing from RAM?

--

demmel products
Radnitzkygasse 43
A-1100 Vienna / Austria / Europe
Voice: +43-1-6894700-0
Fax: +43-1-6894700-40
Email: d...@demmel.com
WWW: http://www.demmel.com
--

demmel products
Radnitzkygasse 43
A-1100 Vienna / Austria / Europe
Voice: +43-1-6894700-0
Fax: +43-1-6894700-40
Email: d...@demmel.com
WWW: http://www.demmel.com
----Original Message----
From: l...
[mailto:l...] On Behalf Of Dave Such
Sent: 10 December 2010 14:45 To: l...
Subject: Re: [lpc2000] Bootloader problems on LPC175x

> My bootloader starts at 0x0000 with application code
> starting at 0x8000. Vector checksum needs to be at
> 0x0014.
>

So, how do you update the vector checksum (or the vectors) without affecting the bootloader?

--
Tim Mitchell

> > My bootloader starts at 0x0000 with application code starting at
> > 0x8000. Vector checksum needs to be at 0x0014.
> >
>
> So, how do you update the vector checksum (or the vectors) without
> affecting the bootloader?

The checksum is only over a small part of the application, so you don't need
to. The bootloader stays and replaces the application.

You can remap where vectors are located--they don't need to be at zero.
Take a look at VTOR in the SCB. Hence, the first thing your app does is
move the VTOR to the app vectors...

Place bootloader at zero, place app at 0x2000 with app's vectors at 0x2000.
On entry to app, assign VTOR to locate vector table at 0x2000 and away you
go...

All your bootloader needs to do is validate that there is an application to
jump to.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore arriving Winter 2010! http://www.soldercore.com

Umm, I still can't get it to power up without going into the boot rom.

I have changed memory_map and flash_placement.xml to relocate the user code at 0x2000, but I am not sure I have done it right.

memory map













If I put the boot code up at the top of the flash, everything works ok, except the flash sectors are very big up there so this is not really a solution.
--
Tim Mitchell

Hi Tim,

> Umm, I still can't get it to power up without going into the boot rom.
>
> I have changed memory_map and flash_placement.xml to relocate the user
> code at 0x2000, but I am not sure I have done it right.

You do have two projects, one for the app, and one for the bootloader?

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore arriving Winter 2010! http://www.soldercore.com