Repository navigation
v0.1.6
Not verified on hardware: every driver and bspClockInit() is covered by
host tests (100% line and branch), but main() is still an empty loop, so
none of it has executed on the board. The register layer, startup file and
vector table were checked against RM0390/PM0214 by review, not on silicon.
Added
-
tools/check_pr_files.shandmake check-pr [BASE=origin/develop]: the
two pull-request file checks that lived as inline shell inci.yml(every
touched source file has a Doxygen@fileblock; every touched
driver/bsp/api/rtos.chas atests/unit/test_<name>.cand every touched
*_reg.his included by a test), now runnable before pushing. CI calls the
same target. Checked by hand against a branch that adds a bare module and
a bare register header: all four error cases fire and the exit is 1. -
make test SANITIZE=1builds and runs the host suite under
AddressSanitizer and UndefinedBehaviorSanitizer with every report fatal,
and CI runs it after the plain suite.gpio.hdocuments an out-of-range
pin as undefined behaviour; this is the build that would see it. All 275
tests pass under it. -
bsp/inc/bsp.h,bsp/src/bsp.c:bspClockInit(rcc, pwr, flash), the
board's 180 MHz bring-up built from the driver calls in order: PWR
clock, HSE bypass (8 MHz from the ST-LINK), regulator scale 1, PLL
M=8/N=360/P=2, wait for the regulator, over-drive, AHB /1, APB1 /4
(45 MHz), APB2 /2 (90 MHz), SYSCLK to the PLL with 5 flash wait states,
then prefetch and caches. Stops at the first failing step and returns
its status.BSP_SYSCLK_HZ/BSP_HCLK_HZ/BSP_PCLK1_HZ/BSP_PCLK2_HZ
name the result for SysTick and UART setup. PLL M/N/P, the prescalers
and the latency are the values in ST's own Nucleo-F446 180 MHz example;
there is no VCO/APB validation inrccPllConfig/rccBusPrescalerConfig;
the limits are_Static_asserts inbsp.hon this one configuration,
andtest_bsp.cchecks that the registersbspClockInit()programs
work out to theBSP_*frequencies. Ten host tests (the whole sequence, the
limit checks, and one timeout orBUSYcase per step). Adds aboard_supportDoxygen group, andmake coveragenow also gatesbsp/srcat 100%. -
drivers/inc/flash.h,drivers/src/flash.c:flashEnableCaches()
sets ACR.PRFTEN, ICEN and DCEN in one read-modify-write that keeps
LATENCY, and returns void (no failure path). No cache reset: the caches
come out of power-on reset empty, as ST'sHAL_Init()also assumes, so
ICRST/DCRST stay unused. Covered by three tests intest_flash.c,
including thatflashSetLatency()preserves the cache bits. -
drivers/inc/pwr.h,drivers/src/pwr.c:pwrEnableOverdrive()
(CR.ODEN, wait CSR.ODRDY, CR.ODSWEN, wait CSR.ODSWRDY) for the 180 MHz
range, with bounded waits likepwrWaitVoltageScaleReady(); ODSWEN is
not written if ODRDY never sets, and CR.VOS is preserved. The ready-flag
waits share one helper, and the timeout constant is renamed
PWR_READY_TIMEOUT_ITERATIONS(same 100000 value).drivers/inc/rcc.h's
ordered bring-up sequence gains the over-drive step between the VOS
wait and the prescaler/SYSCLK-switch steps. Sequence and bit positions
checked against ST's HAL (HAL_PWREx_EnableOverDrive), its
stm32f446xx.h, and its Nucleo-F446 180 MHz example; RM0390 5.1.4 was
not checked directly. -
drivers/inc/systick.h,drivers/src/systick.c: the SysTick driver,
completingdrivers/(7 of 7).systickInit(systick, core_hz, tick_hz)programs LOAD =core_hz / tick_hz - 1, rejecting zero
arguments and any period outside 2 to 2^24 clocks (LOAD 0 never
reloads; LOAD is 24 bits) without touching a register, and starts the
timer last with CLKSOURCE|TICKINT|ENABLE;systickDeinitrestores the
reset state. TheSysTick_Handlerand tick counter stay with the kernel.
Covered bytests/unit/test_systick.c. -
drivers/inc/nvic.h,drivers/src/nvic.c: the NVIC driver
(nvicEnableIrq/DisableIrq,SetPending/ClearPending,
SetPriority/GetPriority, andnvicSetSystemHandlerPriorityfor the
six configurable system handlers via SCB SHPR1-3). Device IRQn is
range-checked (0 toFMPI2C1_Error_IRQn) so a negative system-exception
number can never index the NVIC arrays; priorities are 0-15, shifted into
the implemented top nibble. ISER/ICER/ISPR/ICPR are written as single
bits, never read-modify-written. No PRIGROUP setter:Reset_Handler
already owns it. Covered bytests/unit/test_nvic.c;make lintgains
scopedmisra-c2012-8.7(nvic.c) and2.5/2.3/2.4(nvic_reg.h,
scb_reg.h) suppressions now that those headers are analysed. -
core/inc/scb_reg.h,core/inc/nvic_reg.h,core/inc/systick_reg.h:
added the core-register definitions the NVIC and SysTick drivers and the
kernel's context switch need and the headers lacked. SCB: ICSR
(PENDSVSET/PENDSVCLR/PENDSTSET/PENDSTCLR/VECTACTIVE), SCR
(SLEEPONEXIT/SLEEPDEEP/SEVONPEND),CCR.USERSETMPEND, the SHCSR
active and pended bits, the SHPR1 priority fields, and the six
EXC_RETURN_*values (basic and FPU frames).IRQn_egains the negative
system-exception numbers (MemManage -12, BusFault -11, UsageFault -10,
SVCall -5, PendSV -2, SysTick -1), which index SCB rather than the NVIC;
tools/check_vector_table.awkonly matches non-negative entries, so the
vector-table cross-check is unaffected. SysTick gains the 24-bit
LOAD/VALmasks and theCALIBfields. Each is covered by a test.
Cross-checked against ARM's CMSIScore_cm4.hand ST's
stm32f446xx.h(ST's F446 SVD has no core peripherals). -
tools/install_cppcheck.shbuilds the exact cppcheck version CI pins
(2.13.0) from source into a per-user prefix, verifying the cloned commit
first, andmake lintnow uses it automatically when it is installed
(CPPCHECK=overrides).make lintalso warns whenever the cppcheck it
runs differs from CI's version. Different cppcheck versions report
different MISRA findings; acond ? A : Bexpression passed locally under
2.21 and failed CI under 2.13.0 (misra-c2012-10.6), costing a CI cycle.
Reproduced that exact failure with the pinned build before relying on it.
Changed
-
app/src/main.c: dropped the unreachablereturn 0;after the infinite
loop (MISRA C:2012 Rule 2.1).tests/unit/test_nvic.c: removed a
duplicateCOUNT_OFdefinition. No behaviour change. -
Docs and comments only: comments that narrated how the code used to be
now say how it is, inuart.c,uart.h,iwdg_reg.h,startup, the
Makefile,ci.yml,test_pwr.cand the README Status intro; the reasons
they carried (why BRR rounds once, why the CI workflow must not use
cancel-in-progress) stay. History belongs in this file and in commits.
Also corrected:rcc.hnow says a raising flash latency is already
written whenrccSysclkSwitch()returnsNOT_INITIALIZEDorTIMEOUT
(safe, and left in place); the README's missing-VCO-check limitation is
attributed torccPllConfig(), notrccBusPrescalerConfig(); and
driver_status.hnames the GPIO functions that document a pin@pre
instead of validating it. -
Makefile: the firmware now links with-nostartfilesand
-Wl,--fatal-warnings.Reset_Handleralready does everything crt0
would, and linking crt0 pulled newlib's syscall stubs in ahead of
--gc-sections, which printed four "_close/_lseek/_read/_write
is not implemented" warnings on every link. The link is now silent, so
any new linker warning fails the build. The image is 24 bytes smaller and
the vector table is unchanged. The old Makefile comment calling those
warnings unavoidable is replaced. -
Makefile: the host test and coverage objects now depend on a flags
stamp, the way the firmware objects already did. Before this, editing
WARN_FLAGSorHOST_CFLAGSrebuilt nothing, so a new warning stayed
hidden until a clean build. -
core/inc/*_reg.h,device/inc/*_reg.h: every bit and mask macro now
casts its constant before shifting,((uint32_t)1U << X_Pos)instead of
(1U << X_Pos).1Uhas the essential type of an 8-bit unsigned, so
1U << 17Uis a real MISRA C:2012 Rule 12.2 violation, not the
cppcheck limitation the old comments called it; with the cast the rule
passes under CI's cppcheck 2.13.0. That removes all 50 inline
// cppcheck-suppress misra-c2012-12.2comments fromdrivers/and
bsp/, and the comments that justified them. Generated code is
unchanged. The Makefile's lint notes now say the rule is deliberately
not suppressed anywhere. -
Docs and comments only, from the full review: claims the code or the
manual did not back are corrected or removed.rccBusPrescalerConfig()
no longer says its fields "take effect immediately and synchronously"
(RM0390 has no ready flag, but a divider can apply a few AHB cycles after
the write);uartInit()no longer attributes its clear-UE-first order to
an RM0390 requirement (the order is the safe one either way) and now says
it rewrites only the fields it names, so a re-init of an instance that
used interrupts or CR3 features shoulduartDeinit()first;bsp.hsays
what the_Static_asserts do and do not cover and thattest_bsp.cties
the programmed registers to theBSP_*constants; CONTRIBUTING.md no
longer says an unresolved bare include signals a layering violation (every
inc/directory is on every compile's path, so layering is a convention);
the changelog no longer says a test binds the startup file's literals to
scb_reg.h(it pins the header's side only);iwdg_reg.hnames
IWDG_KEY_ENABLE_ACCESScorrectly; the Makefile comments give the real
CI step order and explain the four libc "not implemented" link warnings.
Checked against RM0390 Rev 6 (March 2021) once the manual was available:
the "RM0390 Table 15" citations pointed at the Low-power mode summary;
the flash wait states are Table 5 (section 3.4.1), and the note beneath
it gives each voltage scale's maximum HCLK (scale 3 120 MHz, scale 2
144 MHz, scale 1 168 MHz, the last two extended by over-drive; an
earlier revision of this entry wrongly said the manual gives no such
figures). Section numbers now match Rev 6, including the chapter numbers
in each register header's file comment: GPIO 7.4 (was 8.4), SYSCFG 8.2
(9.2), EXTI 10.3 (12.3), Flash registers 3.8 (3.7), IWDG 20.4 (21.4),
WWDG 21.6 (20.6), USART 25.6 (19.6), and the voltage regulator and
over-drive text is 5.1.3, not 5.1.4. Also from checking the headers
against the manual:iwdg_reg.hsaid SR must be polled clear before a
PR/RLR write "takes effect", but RM0390 says the wait is needed only
before writing them again;syscfg_reg.hsaid PMC holds Ethernet
selection (only ADCxDC2 on the F446), now notes SYSCFG_CFGR (0x2C) is not
modeled and that PH exists only for EXTI0/1;exti_reg.hnow says bit 19
is reserved in RTSR/FTSR;gpio_reg.hnotes GPIOx_IDR has no fixed
reset value and calls OSPEEDR 0b11 "high speed" as the manual does;
pwr.hno longer says VOSRDY "cannot set" with the PLL off or that a
VOS write with the PLL on is "discarded" (RM0390 says neither);
flash.c's read-back comment now quotes what 3.4.1 actually says;
rcc.hnotes PLLSRC also needs PLLI2S off, which this driver never
enables;flash_reg.hsays OPTCR1's offset comes from ST's CMSIS header.
GPIOA_OSPEEDR resetting to 0 is correct (RM0390 Table 26:GPIOx_OSPEEDR,
x = A..H, resets to 0 and onlyGPIOB_OSPEEDRis0xC0); the F401/F411
value0x0C000000does not apply to the F446. RM0390's over-drive text
also confirms whatpwr.hhad only from ST's HAL: no peripheral clocks
other than PWR's should be on during the over-drive switch. -
drivers/inc/gpio.h,drivers/src/gpio.c:gpioDeinitToReset(port, pin, reset)isgpioDeinit()'s register work with the reset values passed
in;gpioDeinit()is nowgpioDeinitToReset(port, pin, gpioPortResetValues(port)), with no change in behaviour.gpioDeinit()
finds those values by comparingportwithGPIOA/GPIOB, so on the
host (a fake register block at no real address) it always restored
zeros and the part that keeps the debugger connected, putting PA13-15
and PB3/PB4 back into alternate-function mode with their pulls and speed,
was never exercised: a mistake there would have left 100% line and branch
coverage intact. Public for the same reason asgpioPortResetValues().
This is the seam the earlier "not justified yet" note was waiting for: a
wrong SWD restore costs the debugger connection. -
Tests only, from the full review: tests that could not catch the
regression they were written for now can.rccSysclkSwitchis tested
withCFGR.SWstarting at a stale value (its test preloaded SW to 0
despite a comment saying all-1s, so an OR in place of a replace passed),
including the PLL-to-HSI switch-back;rccBusPrescalerConfigwith
HPRE/PPRE1/PPRE2 starting at all-1s;gpioDeinitToResetwith GPIOA's and
GPIOB's real reset values and with three distinct values to catch fields
taken from the wrong register; eachUSART_SRflag and each
RCC_AHB1ENRGPIO enable bit is pinned to its own literal (the existing
tests only showed they filled a range, so a swap passed). Each of these
was checked by introducing the bug and watching the new test fail.
test_bsp_clock_configuration_respects_pll_limitsis removed: it
repeated the_Static_asserts inbsp.hand could not fail separately.
A new BSP test derives the frequencies from the PLL and prescaler fields
bspClockInit()wrote and compares them toBSP_SYSCLK_HZ/BSP_PCLK1_HZ/
BSP_PCLK2_HZ, which the_Static_asserts could not see because bsp.c
programs its register values from separate literals.
test_uart_driver_transmit_sends_every_byte_in_orderand
..._receive_reads_every_byte_in_orderare renamed
..._completes_a_multi_byte_bufferand..._fills_every_element, and
their comments say what a one-word fake DR can show; the init test no
longer claims it observes UE being cleared first; the duplicate
test_uart_driver_transmit_applies_timeout_to_closing_flushis removed. -
Makefile,.github/workflows/ci.yml: warnings are enforced. The
firmware and the host test builds used-Wall -Wextrawith only
-Werror=unused-resultfatal, so a new warning of any other kind passed
CI; the-Wshadow -Wconversion -Wundefclaim in thetest_nvic.centry
below was likewise checked by nothing. Both builds now share one
WARN_FLAGSset,-Wall -Wextra -Wshadow -Wconversion -Wundef -Werror;
the tree already built clean under it at -O0 and -O2 (arm-none-eabi-gcc
15.2 and Apple clang). CI also buildsBUILD=release(-O2) on every
run, so an optimiser-only warning shows up on the pull request and not
for the first time in the release workflow. -
Docs only, from the full review:
CONTRIBUTING.mdgains a Concurrency
section classifying every driver function as single-store (safe on
distinct bits), read-modify-write on a shared register (caller must
serialise) or single-owner, since the drivers had no stated contract and
most of them read-modify-write registers shared across peripherals;
pwrEnableOverdrive()'s precondition now states ST's HAL note that no
other peripheral clock should be enabled during the over-drive switch
(whichbspClockInit()satisfies); and the README lists the known
limitations the review found and left alone (noVTOR/.init_arrayin
startup, the PLLR SYSCLK source,uartInit()/uartDeinit()/
systickInit()edge behaviour, no unwind inbspClockInit()). -
Header and comment hygiene, from the full review. Annotations and types:
USART_SR_RXNEis write-0-to-clear (rc_w0), not "READ only";
NvicRegisters_t::IABRisvolatile constlike every other read-only
register;FPU_FPCCR_LSPACTis "lazy state preservation active".
Includes:gpio.h,flash.h,pwr.h,rcc.handuart.hinclude
<stdint.h>for the types they use instead of relying on their register
header, andbsp.hdrops one it never used. Comments:gpioSetAlternateFunction's
@returnnow lists the pin check,I2SSCRisI2SSRC, the GPIO value
macros all name their register, the SYSCFG EXTICR bit-position wording and
a stale "top-of-file note" cross-reference are fixed, the flash header
listsRDERRamong the omitted SR bits, andbsp.hsays its limits are
_Static_asserts.Makefile,device/inc/rcc_reg.hand
tools/openocd.cfggained their missing final newline. -
Release process and setup docs, from the full review.
docs/VERSIONING.md
now describes how releases were actually cut (arelease/vX.Y.Zbranch
intomain, the changelog link references, the UTC-date convention, the
strict "up to date" branch protection, and the sync-back PR into
develop), where it described adevelop->mainPR and omitted the last
two;CONTRIBUTING.mdagrees. The README listsarm-none-eabi-gdband
nc(needed bymake debug) and the CI tool versions (clang-format 18,
Doxygen 1.18.0, cppcheck 2.13.0, Arm 15.2.rel1) with the warning that other
versions can failmake format-check/make docs, and mentions the
flash.ccoverage exclusion next to the "100% coverage" claim.
SECURITY.mdno longer callsbsp/empty.groups.dox/Doxyfileorder
the layers bottom-up (drivers->bsp->api) like ARCHITECTURE.
release.yml's PR dry run now also triggers onDoxyfileand
CHANGELOG.md- the two files a release PR changes, which it previously
skipped.ci.ymlruns onubuntu-24.04(its apt pins are for that
release;ubuntu-latestwould break them when the alias moves) and passes
the PR base ref throughenv:instead of interpolating it into the script. -
Tests only: closed the remaining gaps the review's contract matrix found
between each driver's documented contract and what the tests pin (29
tests; the mutations below each passed the old suite and fail now).
gpioInitplaces every field on every pin with distinct non-zero values
(includingGPIO_MODE_ANALOG, never accepted by a test before), rejects
each bad argument without touching any of the four registers, and
gpioWritePinwrites BSRR exactly (not OR-ed) and leaves ODR alone;
gpioTogglePinreads ODR, not IDR. AF selection is tested on all 16 pins
at AF 0 and 15 (pins 7/8 straddle AFRL/AFRH). RCC:rccPllConfigwith an
HSI source clears PLLSRC,rccHseEnablein crystal mode clears a stale
HSEBYP, the enables preserve every other CR bit, eachrccSysclkSwitch
source checks its own ready bit. UART: a rejecteduartInitleaves a
running peripheral untouched, STOP 2 -> 1 clears the field, BRR rounds to
nearest (down and tie cases) without 32-bit overflow, non-fault SR bits
are not errors, a NULL output is rejected before waiting,uartReceive
stops at the first fault, waits are flag-specific. NVIC:nvicSetPriority
overwrites and leaves every neighbouring IP byte. PWR/flash/SysTick:
flag-specific waits, other ACR bits preserved,systickInitrejections
leave VAL untouched.bspClockInit: PLL enabled before the VOSRDY wait,
PWR clock first, the documented state after a switch timeout, and no
plain retry. Still not observable through a single-register fake: write
ordering inside a function and UART byte order. -
Tests only: every register header now has a test with literal values for
what the drivers rely on, taken from ST's SVD/HAL and ARM's CMSIS rather
than built from the header's own macros. Before, the field-value macros
were only tested for distinctness, so swappingPWR_CR_VOS_SCALE1and
SCALE3(which would under-volt the 180 MHz bring-up), or exchanging
GPIO_MODE_AFandGPIO_PUPD_DOWN(both 0x2), passed every test. Now
pinned: the VOS/SYSCLK/HPRE/PPRE/PLLP/PLLSRC/GPIO/EXTICR/STOP/AP encodings,
Mskvalues for the fields the drivers shift, theCR/CSR/ACR/CTRL
bits the drivers touch, every base address and pointer macro that was
unpinned (GPIOA..GPIOH,USART1..UART5, RCC, FLASH, PWR, EXTI,
SYSCFG, IWDG, WWDG, NVIC, SCB, FPU, MPU, SysTick),sizeof(RccRegisters_t)
and the offset of every member after a RESERVED gap in each struct. The
constantsstartup_stm32f446re.shard-codes (CPACR address, FPU enable
mask, AIRCR address and the PRIGROUP=3 write) havescb_reg.h's matching
macros pinned to the same literals by a test. Nothing reads the.sfile,
so editing a literal there alone is not caught; the pins catch the header
drifting from the manual. Every literal agreed with the existing macros, so
this found no wrong value - it makes the next wrong header value fail. The EXTI line numbers
16-22 are regression pins only: neither the SVD nor ST's headers define
them. -
drivers/{inc,src}/uart.{h,c}: the TXE/TC/RXNE waits no longer use a
fixed 100000-poll count;uartFlush,uartTransmitByte,uartTransmit,
uartReceiveByteanduartReceivetake a caller-suppliedtimeout
(SR polls; per byte for the buffer functions). A fixed count is about
5-9 ms at 180 MHz -O2 but 11x longer at 16 MHz and 2-3x longer at -O0, so
it timed out spuriously at low baud rates (a TC wait is two frame times:
8 ms at 2400 baud) and whenever a received byte arrived more than a few
milliseconds after the call - which made an echo loop unusable. A receive
wait depends on when the sender next speaks, not on the baud rate, so only
the caller can size it.timeout == 0polls once (a non-blocking check);
UINT32_MAXis an effectively unbounded wait.uart.hdocuments how to
size one. API change, but nothing in the repo calls these yet. Per-poll
cost figures are estimates, not measured on hardware. -
Docs and comments brought in line with the code after the driver and BSP
work:docs/ARCHITECTURE.md(the drivers box omitted Flash and PWR; bsp/
is no longer only "pin mapping";tools/install_cppcheck.sh),
CONTRIBUTING.md(layering diagram nowdrivers->bsp->api->
app, matching ARCHITECTURE;if (status)reasoning; coverage filter
nowdrivers/src+bsp/src; the four workflows; the standalone-command
list),README.md/docs/VERSIONING.md/docs/mainpage.md/docs/groups.dox
(drivers are complete; "0.2.0 is reserved" reworded; BSP described),
SECURITY.md(shared composite actions, graphviz unpinned on purpose),
driver_status.h(DRIVER_STATUS_ERR_BUSYis returned byrcc.c- it
is not reserved for non-blocking drivers),uart.h(no longer "8N1",
nvic.h now exists),rcc.h(CR.VOS resets to 0b11, so "reset default
scale 3" was wrong: scale 3 is what runs while the PLL is off; steps 2
and 3 are interchangeable),pwr.h(over-drive),bsp.h(the state a
failedbspClockInit()leaves behind and that it cannot be retried), and
the Makefile, workflow and Doxyfile comments that still described
bsp/as empty,pwr.cas caller-less, orcleanas only deleting
build/.make lint's suppression rationale is rewritten against what
the pinned cppcheck 2.13.0 actually reports: themisra-c2012-8.7
suppressions on rcc.c, pwr.c, nvic.c, systick.c and bsp.c and four inline
misra-c2012-12.2suppressions in nvic.c were not needed and are removed. -
bsp/inc/bsp.h: the PLL VCO and APB/SYSCLK limits are now
_Static_asserts, so an out-of-rangeBSP_*constant fails any firmware
build, not onlymake test. -
Tests only: closed the gaps a mutation pass over
drivers/andbsp/
found (each mutation passed all 207 tests before, and is caught now).
bspClockInittests assert CR.VOS was written before the PLL stage
(the ordering bug CONTRIBUTING.md says shipped once) and cover the
PLL-already-onBUSYcase;gpioInitis tested with non-zero field
values in every register;rccPllConfigis tested at M 2/63, N 50/432
and PLLP DIV8;uartInit's BRR bounds are tested at exactly 16, 65535
and one past each; a tautological assertion intest_pwr.cwas removed.
Not closed:uartTransmit/uartReceivebyte order is not observable
through a single-register fake DR (the tests that claimed it are renamed
below).gpioDeinit's SWD reset-value restore was also out of reach here
becausegpioPortResetValues()identifies a port by its real address; it
is tested now throughgpioDeinitToReset()(see below).
Fixed
-
tools/check_test_registration.awk: two more ways to get "test compiles,
never runs" past it, found by trying them. ARUN_TEST(test_x);inside a
/* ... */block or an#if 0region still counted as a live registration
(only a//comment or a line starting with*was excluded), and a
definition written asvoidon one line andtest_x(void)on the next was
invisible to both the defined-test and the odd-signature patterns. Every
rule now sees the line with line comments, block comments (one line or
many) and#if 0regions removed, so a commented-out registration is
reported asMISSING RUN_TESTand a test defined inside one as a
RUN_TESTfor a test nothing defines, and a column-0test_x(is
reported as an unrecognised signature. Checked against ten hand-made
variants of the real test tree (BWK awk; not run under mawk, which CI's
Ubuntu image uses). The file mode is now 644 like the other awk scripts. -
Makefile: plainmakebuilt nothing. The flags-stamp rule is the first
target in the file, so it was the default goal andallwas never
reached; the README's "make/make all" was wrong, and CI, the
pre-commit hook and the release workflow all hid it by callingmake all.
.DEFAULT_GOAL := allis now set explicitly. -
Makefile:make debugattached GDB to whatever image was already on the
board, so the symbols of the ELF just built could silently disagree with
the running code, andReset_Handlercould not be stepped. After
attaching it now runsmonitor reset halt,load,monitor reset halt. -
startup/startup_stm32f446re.s:Default_Handlerwas aNOTYPEsymbol
with an even address (0x0800024c). The vector table only ever used the
.thumb_setaliases, which do carry the Thumb bit, so nothing was broken,
but any direct reference to the global symbol (a fallback handler pointer
in the kernel, say) would have loaded an even address and taken an
INVSTATE UsageFault. It is now.type Default_Handler, %function(address
0x0800024d); the vector table words are unchanged. -
Tests only:
test_nvic.cpassed1UL << n(64-bit on a 64-bit host) to
32-bit parameters, a-Wconversionwarning; every test file now compiles
with-Wall -Wextra -Wshadow -Wconversion -Wundefand no warnings. -
tools/: the repo's own consistency checks are harder to fool (full
review).check_test_registration.awkcounted a commented-out
// RUN_TEST(test_x);as registered, which is exactly the "test compiles,
passes, never runs" failure it exists to catch: only a live statement
counts now, a duplicate registration, a commented-out one, and a test
function with a signature other thanvoid test_x(void)(invisible to
the strict pattern) are each reported, and finding no tests at all fails.
check_vector_table.awkonly compared the 97 peripheral slots; it now
also checks the 16 architecturally fixed core words and that each
negativeIRQn_eentry (SVCall, PendSV, SysTick, MemManage, BusFault,
UsageFault) names the vector word it claims - a swapped SVC/PendSV/SysTick
slot used to pass - and that the table has exactly 97 peripheral slots
and no duplicate IRQn.install_cppcheck.shstages the install and swaps
it into place only after the binary passes a real cppcheck+MISRA run
(previously an interrupted run could leave abin/cppcheckwithout its
cfg/thatmake lintthen trusted), restoring the previous install on
failure, and cleans up on SIGINT/SIGTERM. Newmake hookssets up the
pre-commit hook; README/CONTRIBUTING no longer saychmod +x(the file is
already executable), and now document that the hook checks the working
tree rather than the index and thatgit commit --no-verifyskips it.
Each awk change was checked against a deliberately broken copy. -
Makefile: the build now tracks what it was silently ignoring (found by
the full review). Flags: after aBUILD=debugbuild,make BUILD=releaseprinted "nothing to be done" and left the -O0 image to be
mistaken for a release one, and a partial edit linked a mix of -O0 and -O2
objects; the objects and the ELF now depend on abuild/.flagsstamp that
is rewritten only when the compile/link command lines change, and the ELF
also depends on the linker script (editingSTM32F446RE.lddid not
relink). Host builds:make testandmake coveragehad no header
dependency tracking, so editing a driver or register header could leave
stale test objects and a green run; they now use-MMD -MPlike the
firmware build. Coverage:make coveragedeletes leftover.gcda
files before running (counters accumulate, so a removed or broken test
could keep showing hits and let the 100% gate pass; CI's fresh checkout
was never affected, local runs were). Also:make reno longer races
undermake -j(cleanandallare now sequenced), source discovery is
$(sort)ed so the link order does not depend on the filesystem,
.DELETE_ON_ERRORstops a failedobjcopyleaving a truncated.bin
that looks up to date. The flags stamp compares mtimes, so macOS make
3.81's 1-second resolution can miss a profile switch made within a second
of the previous build - only reachable from a script. Verified by
switching profiles, touching the linker script and headers, and running
make -j4 re. -
drivers/src/nvic.c:nvicDisableIrq()now issuesDSB+ISBafter the
ICER write, andnvicEnableIrq()brackets the ISER write with compiler
barriers, as CMSIS'__NVIC_DisableIRQ()/__NVIC_EnableIRQ()do. Without
the DSB the ICER write can still be in the write buffer when the caller
continues, so an interrupt that was already pending could be taken after
the function returned and break the usual "disable, then touch state the
ISR also uses" pattern; without the compiler barrier an inlined or LTO
build could move stores to ISR-shared state past the enable. Host builds
get a compiler barrier only (there is no NVIC to synchronise); the
dsb/isbinstructions are confirmed in the target object. The
behaviour is not observable in the in-memory fake, so no new test. -
drivers/src/rcc.c:rccHsiDisable(),rccHseDisable()and
rccPllDisable()now wait (bounded, like the enables) for the ready flag
to follow the ON bit down, and returnDRIVER_STATUS_ERR_TIMEOUTif it
does not. The flag drops a few cycles after the ON bit, so a quick
disable-then-enable read a staleHSERDY/PLLRDYand reported success
before the oscillator had restarted; with the PLL that also let
rccSysclkSwitch()'s ready check pass on a stalePLLRDY. ST's HAL waits
for the flag to clear in all three paths (HAL_RCC_OscConfig). Not on
thebspClockInit()path (it starts from reset), so this affects any
later reconfiguration. A timed-outrccHseEnable()/rccPllEnable()
still leaves its ON bit set (a retry reportsBUSY);rcc.hnow says
to call the matching disable first. Six tests (each oscillator: success
preserves every other CR bit; a ready flag that never clears times out). -
drivers/src/flash.c: a comment containing the coverage-exclusion
marker text made gcovr see a second, never-closed exclusion region and
warn on everymake coverage; the comment no longer spells the markers
out (coverage is unchanged at 100%). -
drivers/src/rcc.c: everyrcc*ClockEnable()now reads its enable
register back after setting the bit, so the clock is running before the
caller's first access to the peripheral (e.g.gpioInit()straight
afterrccGpioClockEnable()). ST's HAL does the same in each
__HAL_RCC_*_CLK_ENABLEmacro ("Delay after an RCC peripheral clock
enabling"), which is what this follows; ST's errata sheet itself was not
checked, and the effect cannot be observed in the host tests. -
drivers/src/uart.c:uartTransmit()/uartReceive()with a NULL buffer
and a non-zero length, anduartReceiveByte()with a NULL output, now
returnDRIVER_STATUS_ERR_INVALID_PARAMinstead of dereferencing NULL,
as CONTRIBUTING.md's error-handling contract already requires of every
runtime parameter outside its domain (nvicGetPriority()already did).
A zero length with a NULL buffer is still a successful no-op. Documented
inuart.hand covered by three tests. -
drivers/src/nvic.c: the NVIC functions now reject the reserved vector
positions inside 0 toFMPI2C1_Error_IRQn(61-62, 79-80, 82-83, 85-86,
88-90) withDRIVER_STATUS_ERR_INVALID_PARAM, where #99 accepted them
as "architecturally harmless". Enabling and then pending one vectors
through the zero in startup's vector table, which is a fault. The tests
for the write-1-to-act banks now preload every ISER/ICER/ISPR/ICPR word
with a pattern, so a read-modify-write (ICER |= bit, which on silicon
disables every enabled line) is caught; the system-handler tests
preload SHPR1-3 so a wrong byte-lane mask is caught. Both were found by
mutation testing. -
device/inc/iwdg_reg.h: removedWINR(0x10),IWDG_SR_WVUand
IWDG_WINR_WIN_*, which the F446's IWDG does not have; the struct is
0x10 bytes, not 0x14. ST's F446 SVD andstm32f446xx.hboth define only
KR, PR, RLR and SR (the window option is a feature of other STM32
families). Nothing in the repo used them. RM0390 section 21 itself was
not available to check. -
uartInit()accepted any computed BRR from 1 upward and rejected only 0.
BRR holds USARTDIV x 16, and USARTDIV below 1 cannot be generated: with
16x oversampling the highest baud rate is pclk / 16, which is BRR 16. A
baud rate above that (e.g. 8 MHz at 1 Mbaud, BRR 8) returned
DRIVER_STATUS_OKand configured a baud rate the peripheral cannot
produce. It now returnsDRIVER_STATUS_ERR_INVALID_PARAMfor any BRR
below 16. The old test that asserted BRR 1 was accepted is replaced by
one asserting BRR 16 is the smallest valid value and one covering 1, 8
and 15. -
GPIOA_OSPEEDR_RESETwas0x0C000000(PA13 at very high speed), a value
that belongs to other STM32F4 variants such as the F401/F411. ST's own
STM32F446 SVD, which lists a reset value for every register, has GPIOA's
OSPEEDRat0x00000000(GPIOB's0x000000C0and the other four
non-zero values were right). Left in,gpioDeinit()on PA13 would have
written a very-high-speed setting the chip never resets to. The constant is
removed,gpioPortResetValues()reports 0 for it, and a test pins it. This
corrects the reset table added in v0.1.5.