Files
lab-rv32i-freertos-heap4/README.md
T

2.0 KiB

Karta pracy: FreeRTOS heap_4

Trzy krótkie zadania po kartach pointers i structures:

  1. first-fit + split na arenie 256 B;
  2. lista adresowa + scalanie A | B | C;
  3. niezmodyfikowany FreeRTOS-Kernel V11.3.0 heap_4.c.

Task 3 linkuje upstream portable/MemMang/heap_4.c z commita 9b777ae5c5b8e9e456065a00294d1e5f5f9facf5.

  • AMD64: rzeczywisty algorytm + jednowątkowy adapter sekcji krytycznej.
  • Hazard3: tasks.c, list.c, heap_4.c i oficjalny port RISC-V.
  • RP2350: zgodny core+port z forka Raspberry Pi (4f7299d6ea74) oraz podstawiony stabilny allocator V11.3.0.

Jedno wejście: stemctl

stemctl series cards fetch freertos heap4
stemctl test native-amd64 freertos heap4 1
stemctl test hazard3-sim freertos heap4 2
stemctl debug hazard3-sim freertos heap4 3
stemctl test rp2350 freertos heap4 3
stemctl deploy rp2350 freertos heap4 3 --device /dev/bus/usb/BBB/DDD
stemctl debug rp2350 freertos heap4 3 --device /dev/bus/usb/BBB/DDD
  • debug rp2350: roboczy ELF no_flash ładowany do SRAM.
  • deploy rp2350: trwały obraz w SPI flash, odczytany przez breakpointy.

Kontrakt zadań

Task Sprawdza Wynik kluczowy
1 alignment, header, split wanted + remainder == 256
2 lista po adresie, coalescing 2 bloki -> 1 blok, 96 -> 144 B
3 prawdziwe API FreeRTOS free wraca do F0, minimum nie rośnie, OOM = NULL

Debugowanie Task 3

Automatyczny start: heap4_fragmented_checkpoint.

p g_fragmented_stats
p g_final_stats
p xFreeBytesRemaining
p xMinimumEverFreeBytesRemaining
p xStart
p pxEnd
x/160bx ucHeap
b prvInsertBlockIntoFreeList
b pvPortMalloc
b vPortFree

W UI: Termdebug po lewej; źródło i listing po prawej; bash pod Neovimem. F5 continue, F9 breakpoint, F10 next, F11 step, Shift-F11 finish, F8 stepi, :StudentStack, :StudentMemory, :StudentLst.

Test repozytorium

./tests/test_host.sh
bash -n tools/card-action.sh
./scripts/render_pdf.sh

Źródło i licencja: UPSTREAM.md.