Bootloader Design For Microcontrollers in Embedded Systems
Bootloader Design For Microcontrollers in Embedded Systems
Bootloader Design For Microcontrollers in Embedded Systems
ContentsO
1. Introduction......................................................................................................................................3
Fujitsu FM3 Microcontrollers and Code Library.....................................................................................3
2. IEC 60730 Self-Test Library Structure.................................................................................................3
2.2. Self-Test Library: Structure of Test Routines...................................................................................4
2.2.1 CPU Test and Fow Chart............................................................................................................4
2.2.2 CPU Register Test.....................................................................................................................4
2.2.3 Clock Tests...............................................................................................................................5
2.2.4. Interrupt Test..........................................................................................................................6
2.2.5. ROM/Flash checksum integrity check......................................................................................6
2.2.6. RAM Test (using checkerboard) and Flow Chart.......................................................................8
2.2.7. IO Peripheral Tests..................................................................................................................8
3.3. Fujitsu Self-Test Library Deliverables:............................................................................................9
3. Conclusion......................................................................................................................................10
1. IntroductionO
The Fujitsu self-test library (STL) for the 32-bit ARM Cortex
FM3 Family covers IEC 60730 and IEC60335 requirements. These
libraries use a standard application programming interface (API)
between the system hardware and the application software.
Figures 1A and 1B show the self-test library solution structure.
The Fujitsu Class B routines include two types of processes
start up and periodic runtime self tests:
Pre-Operation Self-Test (POST): These are tests that should
be implemented at system startup. POST tests cover items
such as the CPU, RAM/ROM, and I/O peripherals.
Built-In Self-Test (BIST): These tests should run periodically
while the product is in service.
Fujitsu provides two example projects for this self-test Library:
one is based on the IAR compiler and the other on the Keil
compiler.
As shown in Figure 3B, seven test items are provided: CPU,
Clock, Interrupt, Flash memory, RAM, GPIO and ADC peripheral
tests. CPU test and RAM test are in assembly and all other tests
are coded in C. IEC 60730_demo.c provides an example project
for self-test library calls and an interface for user application
software.
iec60730_b_stl
Keil
example
Root
common
IAR
IEC60730_demo.c
IEC60730_B_STL
CPU
test.s
reg_test()
pc_test()
Clock
test.c
Interrupt
test.c
ClkInit()
ClkTestReset()
ClkCnt()
ClkTest()
ClkMonInMainloop()
IntCntPro()
IntTestInit()
IntTest()
RAM
test.s
ROM
test.c
HardwareCRC16 Gen()
HardwareCRC16 Test()
SoftwareCRC16 Gen()
SoftwareCRC16 Test()
ram_test()
IO test.c
GPIOOutput
Test()
GPIOInput
Test()
ADTest()
AD
test.c
ADTest()
pc_test
pc_test
Jump to
subroutine1
Store
subroutine 1
address
Verify
subroutine 1
address
API Description
The PC test makes use of eight subroutines and validates
whether a PC value from each subroutine is the same as
a pre-defined value.
Use assembly to implement PC test due to access to PC
register directly.
As the PC is highly critical, the test is designed so that
any PC test error detected causes the program to run into
an infinite loop.
Fulfills IEC 60730 Annex H.2.18.10.2
Function Description
...
Jump to
subroutine8
Verify
subroutine 8
address
Store
subroutine 8
address
API Name
reg_test,
API Description
reg_test performs complete test of registers and is
implemented in privilege mode as POST.
Assembly is used to implement register tests due to
access to registers directly.
4
API name
ClkInit, ClkTestReset, ClkCnt, ClkMonInMainloop
Function Description
Fujitsu uses the checkerboard method to test the W/R
operation of registers; different test patterns are used
for different registers. The checkerboard method is very
effective for detecting stuck-at errors.
API description
ClkInit: Set to clock test variable (upper/lower frequency
value, threshold value).
ClkReset: Clear clock test flag
ClkTest: Verify if clock frequency is in pre-defined range
(called in watch counter interrupt handler).
Start
Reverse the
pattern
Read register
Read register
Verify if read
data is same with write
data
Verify if read
data is same with write
data
Return
R2
R13
(PPS or MPS)
R3
R4
R14
(LR)
R5
ASPR
R6
R7
PRISMASK
R8
R9
FAULTMASK
R10
R11
R12
BASEPRI
Special register
Main loop
ClkMonInMainloop
ClkTest
ClkCnt
Freq++
Freq
Check if freq is in
(lower, upper)
Int occurrence
flag
Monitored clock
Times
>threshold
Dependent clock
Interrupt Test
API name
IntTest, IntInit
API description
IntInit initializes lower and upper occurrence frequency
of interrupts to be tested.
IntTest should be called in a certain period. It verifies if
occurrence frequency of interrupts is in the setting range.
User code
Timer 3 interrupt
Timer 0 interrupt
Timer 1 interrupt
Timer 2 interrupt
User code
User code
User code
User code
freq[0]--
freq[1]--
freq[2]--
freq[3]--
User code
User code
User code
User code
return
return
return
return
Main loop
Reach 10s
timing?
IntTest(&intpar)
error
IntErrorHandle
No error
User code
:CRC
:DMA
:CPU
CRC calculation ()
Initialization ()
Data writting ()
Start ()
Data writting ()
Data writting ()
CRC reading ()
HardwareCRCTest
(FM3 MCU)
SoftwareCRCTest
(other MCU)
Build-in
Hardware CRC
generator
D0,D1,D2DN
Software CRC
arithmetic
D0,D1,D2DN
Generate
CRC code
Write
D0,D1,D2DN
CRC
code
CRC
code
D0,D1,D2DN
Software CRC
arithmetic
D0,D1,D2DN
D0,D1,D2DN
D0,D1,D2DN
D0,D1,D2DN
Generate
CRC code
CRC code
CRC
code
RAM Test
Function Description
API Names
ram_test
API description
Start
Write 0x55555555
to the address in
RAM area
Write 0xAAAAAAAA
to the address in
RAM area
end
GPIO Test
API Name
GPIOInputTest
GPIOOutputTest
API description
GPIOInputTest can check if selected IO input value is the
same as the expected value. This test is POST and should
be done before user code initialization.
N/A
ADE
PFR
DDR
PCR
EPFR
Disconnect
*0
0
0
0
1
Valid
Disconnect
*1
Disconnect
*2
Valid
*3
Valid
*4
GPIOOutputTest
GPIOInputputTest
Start
Start
Check if read
data is same with write
data
Check if read
data is same with write
data
Return
TEST_ERROR
Return
TEST_ERROR
Return
TEST_NORMAL
Return
TEST_NORMAL
ADTest
Check if
convert finish
N
Select A/D
channel
Y
Get A/D convert
vlue
Return
TEST_ERROR
Y
Return
TEST_NORMAL
ADTest
Annex 2.18.8
API Description
ADTest samples the signal from a selected A/D channel
and checks if the AD convert value is in the expected
range. If the program cannot match the range, the
program calls the AD error handler routine. This routine
is a Pre-Operation Self-Test or POST, which should be
implemented during the startup procedure.
Scan mode is used. Multi-channel mode can be tested at
the same time.
3. ConclusionO
The introduction of IEC/UL 60730 into the design of white
goods and other appliances will add a new level of safety
for consumers. By taking advantage of Fujitsus FM3 Family
MCUs, design teams can comply with the regulations while
maintaining or reducing electronic system cost. Use of these
MCUs and the Self-Test Library enables teams to create a strong
system-level development platform and achieve superior
performance, fast time to market and energy efficiency.
Corporate Headquarters
1250 E. Arques Avenue, M/S 333, Sunnyvale, CA 94085-5401
Tel: (800) 866-8608 Fax: (408) 737-5999
E-mail: [email protected] | Website: http://us.fujitsu.com/semi