mirror of
https://github.com/rfivet/stm32bringup.git
synced 2025-02-21 05:37:09 -05:00
Insure consistency between code and documentation.
This commit is contained in:
parent
2ee50ead2a
commit
5b5a13f353
@ -1,8 +1,9 @@
|
||||
# Makefile -- sign32
|
||||
# Copyright (c) 2021 Renaud Fivet
|
||||
# Copyright (c) 2021-2025 Renaud Fivet
|
||||
|
||||
# silence unused parameter warning
|
||||
WARNINGS=-pedantic -Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter
|
||||
CFLAGS = $(WARNINGS) -O2
|
||||
LDFLAGS = -s
|
||||
|
||||
all: sign32
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* dht11main.c -- sample DHT11 sensor */
|
||||
/* Copyright (c) 2020-2021 Renaud Fivet */
|
||||
/* Copyright (c) 2020-2023 Renaud Fivet */
|
||||
#include <stdio.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "dht11.h"
|
||||
|
||||
int main( void) {
|
||||
static unsigned last ;
|
||||
unsigned last = 0 ;
|
||||
|
||||
dht11_init() ;
|
||||
for( ;;)
|
||||
@ -17,7 +17,8 @@ int main( void) {
|
||||
if( 2 == (last % 5)) /* every 5 seconds starting 2s after boot */
|
||||
switch( dht11_read()) {
|
||||
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 ;
|
||||
case DHT11_FAIL_TOUT:
|
||||
puts( "Timeout") ;
|
||||
|
@ -71,7 +71,7 @@ void kputu( unsigned u) {
|
||||
}
|
||||
|
||||
int main( void) {
|
||||
static unsigned last ;
|
||||
unsigned last = 0 ;
|
||||
|
||||
for( ;;)
|
||||
if( last != uptime) {
|
||||
|
@ -195,7 +195,7 @@ static void display( unsigned u, const char *s) {
|
||||
}
|
||||
|
||||
int main( void) {
|
||||
static unsigned last ;
|
||||
unsigned last = 0 ;
|
||||
|
||||
for( ;;)
|
||||
if( last != uptime) {
|
||||
@ -284,7 +284,7 @@ The build now complete successfully.
|
||||
$ make
|
||||
f030f4.elf
|
||||
text data bss dec hex filename
|
||||
1325 0 12 1337 539 f030f4.elf
|
||||
1317 0 8 1325 52d f030f4.elf
|
||||
f030f4.hex
|
||||
f030f4.bin
|
||||
</pre>
|
||||
|
@ -88,7 +88,7 @@ Build terminates successfully producing the same executable as before.
|
||||
$ make
|
||||
f030f4.elf from startup.o uplow.2.o uptime.o
|
||||
text data bss dec hex filename
|
||||
1325 0 12 1337 539 f030f4.elf
|
||||
1317 0 8 1325 52d f030f4.elf
|
||||
f030f4.hex
|
||||
f030f4.bin
|
||||
</pre>
|
||||
|
@ -310,7 +310,7 @@ Build complete successfully, this is for PLL HSE board configuration.
|
||||
$ make
|
||||
f030f4.elf from startup.o clocks.o uptime.o
|
||||
text data bss dec hex filename
|
||||
1441 0 12 1453 5ad f030f4.elf
|
||||
1433 0 8 1441 5a1 f030f4.elf
|
||||
f030f4.hex
|
||||
f030f4.bin
|
||||
</pre>
|
||||
|
@ -246,7 +246,7 @@ Build completes successfully
|
||||
$ make
|
||||
f030f4.elf from startup.txeie.o txeie.o uptime.o
|
||||
text data bss dec hex filename
|
||||
1641 0 20 1661 67d f030f4.elf
|
||||
1633 0 16 1649 671 f030f4.elf
|
||||
f030f4.hex
|
||||
f030f4.bin
|
||||
</pre>
|
||||
|
@ -220,7 +220,7 @@ Based on this API, I write <b>dht11main.c</b>.
|
||||
#include "dht11.h"
|
||||
|
||||
int main() {
|
||||
static unsigned last ;
|
||||
unsigned last = 0 ;
|
||||
|
||||
dht11_init() ;
|
||||
for( ;;)
|
||||
@ -408,7 +408,7 @@ Build completes successfully
|
||||
$ make
|
||||
f030f4.elf from startup.txeie.o gpioa.o dht11main.o dht11.o
|
||||
text data bss dec hex filename
|
||||
1877 0 24 1901 76d f030f4.elf
|
||||
1861 0 20 1881 759 f030f4.elf
|
||||
f030f4.hex
|
||||
f030f4.bin
|
||||
</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
|
||||
correct.
|
||||
|
||||
<hr>© 2020-2024 Renaud Fivet
|
||||
<hr>© 2020-2025 Renaud Fivet
|
||||
</body>
|
||||
</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
|
||||
text data bss dec hex filename
|
||||
2464 0 16 2480 9b0 f030f4.elf
|
||||
2408 0 16 2424 978 f030f4.elf
|
||||
f030f4.hex
|
||||
f030f4.bin
|
||||
</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
|
||||
want to use.
|
||||
|
||||
<hr>© 2020-2024 Renaud Fivet
|
||||
<hr>© 2020-2025 Renaud Fivet
|
||||
</body>
|
||||
</html>
|
||||
|
@ -130,7 +130,7 @@ environment in use (Cygwin, MSYS2 and other).
|
||||
ifeq (linux, $(findstring linux, $(MAKE_HOST)))
|
||||
INSTALLDIR = $(HOME)/Packages
|
||||
#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
|
||||
DRIVE = d
|
||||
ifeq (cygwin, $(findstring cygwin, $(MAKE_HOST)))
|
||||
@ -142,7 +142,7 @@ else
|
||||
endif
|
||||
INSTALLDIR = $(OSDRIVE)/Program Files (x86)
|
||||
#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
|
||||
|
||||
GCCDIR = $(INSTALLDIR)/$(REVDIR)
|
||||
@ -174,6 +174,6 @@ changes.
|
||||
<a href="37_inram.html">Next</a>, I will (re)build to execute code in RAM
|
||||
instead of FLASH.
|
||||
|
||||
<hr>© 2020-2024 Renaud Fivet
|
||||
<hr>© 2020-2025 Renaud Fivet
|
||||
</body>
|
||||
</html>
|
||||
|
@ -384,7 +384,7 @@ ledtick.elf: ledtick.o
|
||||
cstartup.elf: cstartup.o
|
||||
|
||||
%.elf:
|
||||
@echo $@
|
||||
@echo $@ from $+
|
||||
$(CC) $(CPU) -T$(LD_SCRIPT) $(LDFLAGS) -nostartfiles -o $@ $+
|
||||
$(SIZE) $@
|
||||
$(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
|
||||
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
|
||||
|
||||
<pre>
|
||||
$ 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
|
||||
1164 0 20 1184 4a0 f030f4.elf
|
||||
1163 0 208 1371 55b f030f4.elf
|
||||
f030f4.hex
|
||||
f030f4.0x20000800.bin
|
||||
</pre>
|
||||
@ -419,19 +430,18 @@ $ stm32flash -g 0x20000800
|
||||
|
||||
<h2>Caveat: stm32flash v0.6 intel hex bug</h2>
|
||||
|
||||
At the time of writing, <b>stm32flash</b> v0.6 has a bug that prevents
|
||||
writing intel hex files correctly at address other than the origin of
|
||||
the Flash. A bug fix and the possibility to directly read the base
|
||||
address from the intel hex file are planned to be included in v0.7.
|
||||
<b>stm32flash</b> v0.6 had a bug that prevents writing intel hex files
|
||||
correctly at address other than the origin of the Flash. A bug fix and the
|
||||
possibility to directly read the base address from the intel hex file was
|
||||
merged in v0.7.
|
||||
<p>
|
||||
Until v0.7 is out, I am using my own patched version of stm32flash or
|
||||
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
|
||||
I have 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:
|
||||
|
||||
<pre>stm32flash -x file.hex COM#</pre>
|
||||
|
||||
This patch is scheduled to be merged in v0.8.
|
||||
|
||||
<h2>Testing</h2>
|
||||
|
||||
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
|
||||
doing CRC32 validation of the code.
|
||||
|
||||
<hr>© 2020-2024 Renaud Fivet
|
||||
<hr>© 2020-2025 Renaud Fivet
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* 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
|
||||
*/
|
||||
@ -19,7 +19,7 @@ void kputu( unsigned u) {
|
||||
}
|
||||
|
||||
int main( void) {
|
||||
static unsigned last ;
|
||||
unsigned last = 0 ;
|
||||
|
||||
for( ;;)
|
||||
if( last != uptime) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user