Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

<moshez> ok, I will not marry Jo-Con-El's cow.


devel / comp.arch.embedded / MCU reset and internal SRAM starting values

SubjectAuthor
* MCU reset and internal SRAM starting valuespozz
`* Re: MCU reset and internal SRAM starting valuesStef
 `- Re: MCU reset and internal SRAM starting valuespozz

1
MCU reset and internal SRAM starting values

<t2ju2f$eff$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=849&group=comp.arch.embedded#849

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: pozzugno@gmail.com (pozz)
Newsgroups: comp.arch.embedded
Subject: MCU reset and internal SRAM starting values
Date: Wed, 6 Apr 2022 13:37:51 +0200
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <t2ju2f$eff$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 6 Apr 2022 11:37:51 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cfeb03cb842b0bdfd6bfcb1c8097b8bb";
logging-data="14831"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Fy7SSBckR/Fda+Ih53gReRmbPakP13b4="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:zEYGMJvRaSjiSkiyCsh3NbIEkVA=
 by: pozz - Wed, 6 Apr 2022 11:37 UTC

I often use with success a simple way to implement a bootloader:

#define START_MAGIC 0xAA55AA55
uint32_t start_application __attribute__((section=".noinit"));

void main(void) {
...
if (start_application == START_MAGIC) {
start_application = ~START_MAGIC;
launch_application();
}
/* Stay in bootloader and wait for new application from
* USART, SPI, USB, whatever. */
...
start_application = START_MAGIC;
ResetMCU(); /* It's NVIC_SystemReset() */
}

I don't use launch_application() after download, because I think it
isn't good to start the application with some already configured
peripherals (USART, SPI, USB). I know I can deinitialize peripherals and
clocks before launch_application(), but the technique above it's much
more simple.
Of course, start_application variable shouldn't be touched after a
reset, so I put it in noinit section.

Recently I tried to implement a bootloader on a LPC546XX from NXP and I
noticed it didn't work. After some investigation I found that
start_application variable is reset to zero immediately after ResetMCU().
After other investigation I noticed that the first 4kB space of SRAM
doesn't change after a reset, while the next 4kB space is really put to
zero.
I changed the location of start_application variable to the first 4kB
space and the bootloader started working perfectly.

This is the first time I see this behaviour, so my question.

When can you trust that internal SRAM content isn't changed when the MCU
core is reset?

Re: MCU reset and internal SRAM starting values

<nnd$4414f7cd$09712b7f@97dd424c2ead8fc7>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=850&group=comp.arch.embedded#850

  copy link   Newsgroups: comp.arch.embedded
Newsgroups: comp.arch.embedded
From: me@this.is.invalid (Stef)
Subject: Re: MCU reset and internal SRAM starting values
References: <t2ju2f$eff$1@dont-email.me>
Mail-Copies-To: nobody
User-Agent: slrn/1.0.3 (Linux)
Message-ID: <nnd$4414f7cd$09712b7f@97dd424c2ead8fc7>
Organization: Newsxs
Date: Wed, 06 Apr 2022 14:07:09 +0200
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!feeder.usenetexpress.com!tr1.eu1.usenetexpress.com!94.232.112.244.MISMATCH!feed.abavia.com!abe004.abavia.com!abp002.abavia.com!news.newsxs.nl!not-for-mail
Lines: 52
Injection-Date: Wed, 06 Apr 2022 14:07:09 +0200
Injection-Info: news.newsxs.nl; mail-complaints-to="abuse@newsxs.nl"
 by: Stef - Wed, 6 Apr 2022 12:07 UTC

On 2022-04-06 pozz wrote in comp.arch.embedded:
> I often use with success a simple way to implement a bootloader:
>
>
> #define START_MAGIC 0xAA55AA55
> uint32_t start_application __attribute__((section=".noinit"));
>
> void main(void) {
> ...
> if (start_application == START_MAGIC) {
> start_application = ~START_MAGIC;
> launch_application();
> }
> /* Stay in bootloader and wait for new application from
> * USART, SPI, USB, whatever. */
> ...
> start_application = START_MAGIC;
> ResetMCU(); /* It's NVIC_SystemReset() */
> }
>
>
> I don't use launch_application() after download, because I think it
> isn't good to start the application with some already configured
> peripherals (USART, SPI, USB). I know I can deinitialize peripherals and
> clocks before launch_application(), but the technique above it's much
> more simple.
> Of course, start_application variable shouldn't be touched after a
> reset, so I put it in noinit section.
>
> Recently I tried to implement a bootloader on a LPC546XX from NXP and I
> noticed it didn't work. After some investigation I found that
> start_application variable is reset to zero immediately after ResetMCU().
> After other investigation I noticed that the first 4kB space of SRAM
> doesn't change after a reset, while the next 4kB space is really put to
> zero.
> I changed the location of start_application variable to the first 4kB
> space and the bootloader started working perfectly.
>
> This is the first time I see this behaviour, so my question.
>
> When can you trust that internal SRAM content isn't changed when the MCU
> core is reset?

The LPC546XX seems to have a quite complicated boot process that
validates boot images. It may use (and afterwards clear?) some ram for
that?

--
Stef

Happiness isn't having what you want, it's wanting what you have.

Re: MCU reset and internal SRAM starting values

<t2k5he$4s1$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=851&group=comp.arch.embedded#851

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: pozzugno@gmail.com (pozz)
Newsgroups: comp.arch.embedded
Subject: Re: MCU reset and internal SRAM starting values
Date: Wed, 6 Apr 2022 15:45:19 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <t2k5he$4s1$1@dont-email.me>
References: <t2ju2f$eff$1@dont-email.me>
<nnd$4414f7cd$09712b7f@97dd424c2ead8fc7>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 6 Apr 2022 13:45:18 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cfeb03cb842b0bdfd6bfcb1c8097b8bb";
logging-data="4993"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18kNvs3e8x8xCrvioMmqWSbmwQ/49kF75w="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:FfvWJQGr8EN28itn4/fI+Prb4O4=
In-Reply-To: <nnd$4414f7cd$09712b7f@97dd424c2ead8fc7>
 by: pozz - Wed, 6 Apr 2022 13:45 UTC

Il 06/04/2022 14:07, Stef ha scritto:
> On 2022-04-06 pozz wrote in comp.arch.embedded:
[...]
>> When can you trust that internal SRAM content isn't changed when the MCU
>> core is reset?
>
> The LPC546XX seems to have a quite complicated boot process that
> validates boot images. It may use (and afterwards clear?) some ram for
> that?

Good point, LPC546XX has a ROM bootloader that always starts at the
beginning (and I think even after a software reset like NVIC_SystemReset).

However I couldn't find any info about the SRAM it uses, but this could
explain the behaviour I observed.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor