mirror of
https://github.com/rfivet/stm32bringup.git
synced 2025-04-22 02:52:22 -04:00
Insure consistency between code and documentation.
This commit is contained in:
parent
2ee50ead2a
commit
5b5a13f353
@ -1,8 +1,9 @@
|
|||||||
# Makefile -- sign32
|
# Makefile -- sign32
|
||||||
# Copyright (c) 2021 Renaud Fivet
|
# Copyright (c) 2021-2025 Renaud Fivet
|
||||||
|
|
||||||
# silence unused parameter warning
|
# silence unused parameter warning
|
||||||
WARNINGS=-pedantic -Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter
|
WARNINGS=-pedantic -Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter
|
||||||
CFLAGS = $(WARNINGS) -O2
|
CFLAGS = $(WARNINGS) -O2
|
||||||
|
LDFLAGS = -s
|
||||||
|
|
||||||
all: sign32
|
all: sign32
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
/* dht11main.c -- sample DHT11 sensor */
|
/* dht11main.c -- sample DHT11 sensor */
|
||||||
/* Copyright (c) 2020-2021 Renaud Fivet */
|
/* Copyright (c) 2020-2023 Renaud Fivet */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "dht11.h"
|
#include "dht11.h"
|
||||||
|
|
||||||
int main( void) {
|
int main( void) {
|
||||||
static unsigned last ;
|
unsigned last = 0 ;
|
||||||
|
|
||||||
dht11_init() ;
|
dht11_init() ;
|
||||||
for( ;;)
|
for( ;;)
|
||||||
@ -17,7 +17,8 @@ int main( void) {
|
|||||||
if( 2 == (last % 5)) /* every 5 seconds starting 2s after boot */
|
if( 2 == (last % 5)) /* every 5 seconds starting 2s after boot */
|
||||||
switch( dht11_read()) {
|
switch( dht11_read()) {
|
||||||
case DHT11_SUCCESS:
|
case DHT11_SUCCESS:
|
||||||
printf( "%u%%RH, %d.%uC\n", dht11_humid, dht11_tempc, dht11_tempf) ;
|
printf( "%u%%RH, %d.%uC\n", dht11_humid, dht11_tempc,
|
||||||
|
dht11_tempf) ;
|
||||||
break ;
|
break ;
|
||||||
case DHT11_FAIL_TOUT:
|
case DHT11_FAIL_TOUT:
|
||||||
puts( "Timeout") ;
|
puts( "Timeout") ;
|
||||||
|
@ -71,7 +71,7 @@ void kputu( unsigned u) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main( void) {
|
int main( void) {
|
||||||
static unsigned last ;
|
unsigned last = 0 ;
|
||||||
|
|
||||||
for( ;;)
|
for( ;;)
|
||||||
if( last != uptime) {
|
if( last != uptime) {
|
||||||
|
@ -195,7 +195,7 @@ static void display( unsigned u, const char *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main( void) {
|
int main( void) {
|
||||||
static unsigned last ;
|
unsigned last = 0 ;
|
||||||
|
|
||||||
for( ;;)
|
for( ;;)
|
||||||
if( last != uptime) {
|
if( last != uptime) {
|
||||||
@ -284,7 +284,7 @@ The build now complete successfully.
|
|||||||
$ make
|
$ make
|
||||||
f030f4.elf
|
f030f4.elf
|
||||||
text data bss dec hex filename
|
text data bss dec hex filename
|
||||||
1325 0 12 1337 539 f030f4.elf
|
1317 0 8 1325 52d f030f4.elf
|
||||||
f030f4.hex
|
f030f4.hex
|
||||||
f030f4.bin
|
f030f4.bin
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -88,7 +88,7 @@ Build terminates successfully producing the same executable as before.
|
|||||||
$ make
|
$ make
|
||||||
f030f4.elf from startup.o uplow.2.o uptime.o
|
f030f4.elf from startup.o uplow.2.o uptime.o
|
||||||
text data bss dec hex filename
|
text data bss dec hex filename
|
||||||
1325 0 12 1337 539 f030f4.elf
|
1317 0 8 1325 52d f030f4.elf
|
||||||
f030f4.hex
|
f030f4.hex
|
||||||
f030f4.bin
|
f030f4.bin
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -310,7 +310,7 @@ Build complete successfully, this is for PLL HSE board configuration.
|
|||||||
$ make
|
$ make
|
||||||
f030f4.elf from startup.o clocks.o uptime.o
|
f030f4.elf from startup.o clocks.o uptime.o
|
||||||
text data bss dec hex filename
|
text data bss dec hex filename
|
||||||
1441 0 12 1453 5ad f030f4.elf
|
1433 0 8 1441 5a1 f030f4.elf
|
||||||
f030f4.hex
|
f030f4.hex
|
||||||
f030f4.bin
|
f030f4.bin
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -246,7 +246,7 @@ Build completes successfully
|
|||||||
$ make
|
$ make
|
||||||
f030f4.elf from startup.txeie.o txeie.o uptime.o
|
f030f4.elf from startup.txeie.o txeie.o uptime.o
|
||||||
text data bss dec hex filename
|
text data bss dec hex filename
|
||||||
1641 0 20 1661 67d f030f4.elf
|
1633 0 16 1649 671 f030f4.elf
|
||||||
f030f4.hex
|
f030f4.hex
|
||||||
f030f4.bin
|
f030f4.bin
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -220,7 +220,7 @@ Based on this API, I write <b>dht11main.c</b>.
|
|||||||
#include "dht11.h"
|
#include "dht11.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
static unsigned last ;
|
unsigned last = 0 ;
|
||||||
|
|
||||||
dht11_init() ;
|
dht11_init() ;
|
||||||
for( ;;)
|
for( ;;)
|
||||||
@ -408,7 +408,7 @@ Build completes successfully
|
|||||||
$ make
|
$ make
|
||||||
f030f4.elf from startup.txeie.o gpioa.o dht11main.o dht11.o
|
f030f4.elf from startup.txeie.o gpioa.o dht11main.o dht11.o
|
||||||
text data bss dec hex filename
|
text data bss dec hex filename
|
||||||
1877 0 24 1901 76d f030f4.elf
|
1861 0 20 1881 759 f030f4.elf
|
||||||
f030f4.hex
|
f030f4.hex
|
||||||
f030f4.bin
|
f030f4.bin
|
||||||
</pre>
|
</pre>
|
||||||
@ -429,6 +429,6 @@ can read the values reported by the DHT11 sensor.
|
|||||||
<a href="32_errata.html">Next</a>, I will investigate if the values read are
|
<a href="32_errata.html">Next</a>, I will investigate if the values read are
|
||||||
correct.
|
correct.
|
||||||
|
|
||||||
<hr>© 2020-2024 Renaud Fivet
|
<hr>© 2020-2025 Renaud Fivet
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -340,7 +340,7 @@ adc.c:232:3: warning: #warning HCLK is not multiple of 8 MHz [-Wcpp]
|
|||||||
| ^~~~~~~
|
| ^~~~~~~
|
||||||
f030f4.elf from startup.txeie.o adc.o adcmain.o
|
f030f4.elf from startup.txeie.o adc.o adcmain.o
|
||||||
text data bss dec hex filename
|
text data bss dec hex filename
|
||||||
2464 0 16 2480 9b0 f030f4.elf
|
2408 0 16 2424 978 f030f4.elf
|
||||||
f030f4.hex
|
f030f4.hex
|
||||||
f030f4.bin
|
f030f4.bin
|
||||||
</pre>
|
</pre>
|
||||||
@ -366,6 +366,6 @@ point measured in factory for the STM32F030 family members.
|
|||||||
means taking two measurements as far apart as possible in the working range I
|
means taking two measurements as far apart as possible in the working range I
|
||||||
want to use.
|
want to use.
|
||||||
|
|
||||||
<hr>© 2020-2024 Renaud Fivet
|
<hr>© 2020-2025 Renaud Fivet
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -130,7 +130,7 @@ environment in use (Cygwin, MSYS2 and other).
|
|||||||
ifeq (linux, $(findstring linux, $(MAKE_HOST)))
|
ifeq (linux, $(findstring linux, $(MAKE_HOST)))
|
||||||
INSTALLDIR = $(HOME)/Packages
|
INSTALLDIR = $(HOME)/Packages
|
||||||
#REVDIR = gcc-arm-none-eabi-10-2020-q4-major
|
#REVDIR = gcc-arm-none-eabi-10-2020-q4-major
|
||||||
REVDIR = arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi
|
REVDIR = arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-eabi
|
||||||
else
|
else
|
||||||
DRIVE = d
|
DRIVE = d
|
||||||
ifeq (cygwin, $(findstring cygwin, $(MAKE_HOST)))
|
ifeq (cygwin, $(findstring cygwin, $(MAKE_HOST)))
|
||||||
@ -142,7 +142,7 @@ else
|
|||||||
endif
|
endif
|
||||||
INSTALLDIR = $(OSDRIVE)/Program Files (x86)
|
INSTALLDIR = $(OSDRIVE)/Program Files (x86)
|
||||||
#REVDIR = GNU Arm Embedded Toolchain/10 2020-q4-major
|
#REVDIR = GNU Arm Embedded Toolchain/10 2020-q4-major
|
||||||
REVDIR = GNU Arm Embedded Toolchain/arm-gnu-toolchain-13.3.rel1-mingw-w64-i686-arm-none-eabi
|
REVDIR = GNU Arm Embedded Toolchain/arm-gnu-toolchain-14.2.rel1-mingw-w64-i686-arm-none-eabi
|
||||||
endif
|
endif
|
||||||
|
|
||||||
GCCDIR = $(INSTALLDIR)/$(REVDIR)
|
GCCDIR = $(INSTALLDIR)/$(REVDIR)
|
||||||
@ -174,6 +174,6 @@ changes.
|
|||||||
<a href="37_inram.html">Next</a>, I will (re)build to execute code in RAM
|
<a href="37_inram.html">Next</a>, I will (re)build to execute code in RAM
|
||||||
instead of FLASH.
|
instead of FLASH.
|
||||||
|
|
||||||
<hr>© 2020-2024 Renaud Fivet
|
<hr>© 2020-2025 Renaud Fivet
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -384,7 +384,7 @@ ledtick.elf: ledtick.o
|
|||||||
cstartup.elf: cstartup.o
|
cstartup.elf: cstartup.o
|
||||||
|
|
||||||
%.elf:
|
%.elf:
|
||||||
@echo $@
|
@echo $@ from $+
|
||||||
$(CC) $(CPU) -T$(LD_SCRIPT) $(LDFLAGS) -nostartfiles -o $@ $+
|
$(CC) $(CPU) -T$(LD_SCRIPT) $(LDFLAGS) -nostartfiles -o $@ $+
|
||||||
$(SIZE) $@
|
$(SIZE) $@
|
||||||
$(OBJDUMP) -hS $@ > $(subst .elf,.lst,$@)
|
$(OBJDUMP) -hS $@ > $(subst .elf,.lst,$@)
|
||||||
@ -397,15 +397,26 @@ The projects composition need to be updated to use the new startup.
|
|||||||
Finally, to keep track of the memory model and the load location, I put
|
Finally, to keep track of the memory model and the load location, I put
|
||||||
the load address in the name of the binary file generated.
|
the load address in the name of the binary file generated.
|
||||||
|
|
||||||
<pre>all: $(PROJECT).$(BINLOC).bin $(PROJECT).hex</pre>
|
<pre>all: $(PROJECT).hex $(PROJECT).$(BINLOC).bin</pre>
|
||||||
|
|
||||||
|
With the corresponding rule
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
%.$(BINLOC).bin: %.elf
|
||||||
|
@echo $@
|
||||||
|
$(OBJCOPY) -O binary $< $@
|
||||||
|
</pre>
|
||||||
|
|
||||||
This way if I build uptime prototype in GORAM memory model
|
This way if I build uptime prototype in GORAM memory model
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
$ make
|
$ make
|
||||||
f030f4.elf
|
f030f4.elf from startup.ram.o txeie.o uptime.1.o libstm32.a
|
||||||
|
Memory region Used Size Region Size %age Used
|
||||||
|
FLASH: 1163 B 2 KB 56.79%
|
||||||
|
RAM: 208 B 2 KB 10.16%
|
||||||
text data bss dec hex filename
|
text data bss dec hex filename
|
||||||
1164 0 20 1184 4a0 f030f4.elf
|
1163 0 208 1371 55b f030f4.elf
|
||||||
f030f4.hex
|
f030f4.hex
|
||||||
f030f4.0x20000800.bin
|
f030f4.0x20000800.bin
|
||||||
</pre>
|
</pre>
|
||||||
@ -419,19 +430,18 @@ $ stm32flash -g 0x20000800
|
|||||||
|
|
||||||
<h2>Caveat: stm32flash v0.6 intel hex bug</h2>
|
<h2>Caveat: stm32flash v0.6 intel hex bug</h2>
|
||||||
|
|
||||||
At the time of writing, <b>stm32flash</b> v0.6 has a bug that prevents
|
<b>stm32flash</b> v0.6 had a bug that prevents writing intel hex files
|
||||||
writing intel hex files correctly at address other than the origin of
|
correctly at address other than the origin of the Flash. A bug fix and the
|
||||||
the Flash. A bug fix and the possibility to directly read the base
|
possibility to directly read the base address from the intel hex file was
|
||||||
address from the intel hex file are planned to be included in v0.7.
|
merged in v0.7.
|
||||||
<p>
|
<p>
|
||||||
Until v0.7 is out, I am using my own patched version of stm32flash or
|
I have branched off my own patched version of <b>stm32flash</b>, I added a
|
||||||
the binary files when I need to test GOFLASH and GORAM memory models.
|
|
||||||
<p>
|
|
||||||
As I branched off my own patched version of <b>stm32flash</b>, I added a
|
|
||||||
<code>-x</code> option to write and execute an intel hex file:
|
<code>-x</code> option to write and execute an intel hex file:
|
||||||
|
|
||||||
<pre>stm32flash -x file.hex COM#</pre>
|
<pre>stm32flash -x file.hex COM#</pre>
|
||||||
|
|
||||||
|
This patch is scheduled to be merged in v0.8.
|
||||||
|
|
||||||
<h2>Testing</h2>
|
<h2>Testing</h2>
|
||||||
|
|
||||||
I build all four memory models and check that they can be loaded and
|
I build all four memory models and check that they can be loaded and
|
||||||
@ -448,6 +458,6 @@ GORAM with <b>STM32 Cube Programmer</b>.
|
|||||||
<a href="38_crc32.html">Next</a>, I will add integrity check at startup by
|
<a href="38_crc32.html">Next</a>, I will add integrity check at startup by
|
||||||
doing CRC32 validation of the code.
|
doing CRC32 validation of the code.
|
||||||
|
|
||||||
<hr>© 2020-2024 Renaud Fivet
|
<hr>© 2020-2025 Renaud Fivet
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* uptime.1.c -- tells how long the system has been running
|
/* uptime.1.c -- tells how long the system has been running
|
||||||
** Copyright (c) 2020 Renaud Fivet
|
** Copyright (c) 2020-2023 Renaud Fivet
|
||||||
**
|
**
|
||||||
** v1 displays the number of seconds elapsed since boot
|
** v1 displays the number of seconds elapsed since boot
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,7 @@ void kputu( unsigned u) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main( void) {
|
int main( void) {
|
||||||
static unsigned last ;
|
unsigned last = 0 ;
|
||||||
|
|
||||||
for( ;;)
|
for( ;;)
|
||||||
if( last != uptime) {
|
if( last != uptime) {
|
||||||
|
2
uptime.c
2
uptime.c
@ -1,5 +1,5 @@
|
|||||||
/* uptime.c -- tells how long the system has been running */
|
/* uptime.c -- tells how long the system has been running */
|
||||||
/* Copyright (c) 2020 Renaud Fivet */
|
/* Copyright (c) 2020-2023 Renaud Fivet */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "system.h" /* uptime, yield() */
|
#include "system.h" /* uptime, yield() */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user