Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/littlefs_sd_shim.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef ROCKETLIB_LITTLEFS_SHIM_H
#define ROCKETLIB_LITTLEFS_SHIM_H
#ifndef ROCKETLIB_LITTLEFS_SD_SHIM_H
#define ROCKETLIB_LITTLEFS_SD_SHIM_H

#include "lfs.h"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Locate littlefs headers and current include patterns.
echo "=== Searching for lfs.h files ==="
fd -a 'lfs.h'

echo -e "\n=== Searching for include patterns related to lfs ==="
rg -nP '#\s*include\s*[<"]lfs\.h[>"]|#\s*include\s*[<"].*lfs.*[>"]' -t c -t h --max-count 20

Repository: waterloo-rocketry/rocketlib

Length of output: 251


🏁 Script executed:

#!/bin/bash
echo "=== Checking for build configuration files ==="
ls -la | grep -E "CMakeLists|Makefile|package.json|\.gitmodules|\.git"

echo -e "\n=== Checking .gitmodules for submodules ==="
cat .gitmodules 2>/dev/null || echo "No .gitmodules found"

echo -e "\n=== Searching for littlefs references in build/config files ==="
rg "littlefs|lfs\.h" -t cmake -t make -t json --max-count 20

echo -e "\n=== Directory structure overview ==="
find . -maxdepth 2 -type d | grep -v "\.git" | sort

Repository: waterloo-rocketry/rocketlib

Length of output: 526


🏁 Script executed:

#!/bin/bash
echo "=== GitHub Actions workflow files ==="
find .github -type f 2>/dev/null | head -20

echo -e "\n=== Checking workflow content ==="
for f in $(find .github -name "*.yml" -o -name "*.yaml" 2>/dev/null); do
  echo "--- $f ---"
  cat "$f"
done

echo -e "\n=== Checking for build configs in subdirectories ==="
find . -maxdepth 2 -name "CMakeLists.txt" -o -name "Makefile" -o -name "*.mk" 2>/dev/null | head -20

echo -e "\n=== Checking for include paths in stm32h7 ==="
ls -la stm32h7/ 2>/dev/null | head -20

Repository: waterloo-rocketry/rocketlib

Length of output: 4723


🏁 Script executed:

#!/bin/bash
echo "=== README or documentation files ==="
find . -maxdepth 2 -iname "README*" -o -iname "*.md" | head -10

echo -e "\n=== Checking git log for littlefs mentions (last 10 commits) ==="
git log --oneline -20 | head -10

echo -e "\n=== Checking if littlefs is mentioned in any config/setup file ==="
rg "littlefs|lfs" -t md -t txt -t rst --max-count 20

echo -e "\n=== Checking include/littlefs_sd_shim.h full content ==="
cat include/littlefs_sd_shim.h

Repository: waterloo-rocketry/rocketlib

Length of output: 789


Move header to platform-specific directory to fix CI lint failure.

The #include "lfs.h" fails clang-tidy because this header is platform-specific (uses STM32H7 types like SD_HandleTypeDef) but resides in include/ which gets checked with only -Iinclude flag, without access to the littlefs dependency. Move include/littlefs_sd_shim.h to stm32h7/ alongside its implementation in stm32h7/littlefs_sd_shim.c.

🧰 Tools
🪛 GitHub Actions: C Lint Check

[error] 4-4: 'lfs.h' file not found

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@include/littlefs_sd_shim.h` at line 4, The header include/littlefs_sd_shim.h
is platform-specific (references STM32H7 types like SD_HandleTypeDef and
includes "lfs.h") and should be moved next to its implementation; relocate
littlefs_sd_shim.h from include/ into the platform directory (stm32h7/)
alongside stm32h7/littlefs_sd_shim.c, update any internal `#include` paths or
project headers referencing littlefs_sd_shim.h to the new location, and ensure
build/CI include paths are adjusted so the file is discovered from stm32h7/
(preserving the same header guard and symbols used by littlefs_sd_shim.c).

#include "stm32h7xx_hal_sd.h"
Expand All @@ -16,4 +16,4 @@ int lfsshim_sd_mount_mbr(lfs_t *lfs, SD_HandleTypeDef *hsd);
}
#endif

#endif // ROCKETLIB_LITTLEFS_SHIM_H
#endif // ROCKETLIB_LITTLEFS_SD_SHIM_H
12 changes: 12 additions & 0 deletions include/mx25l25645g.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef ROCKETLIB_MX25L225645G_H
#define ROCKETLIB_MX25L225645G_H

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif

#endif // ROCKETLIB_MX25L225645G_H
17 changes: 17 additions & 0 deletions include/qspi_flash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef ROCKETLIB_QSPI_FLASH.H
#define ROCKETLIB_QSPI_FLASH .H
Comment on lines +1 to +2
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

cat -n include/qspi_flash.h

Repository: waterloo-rocketry/rocketlib

Length of output: 421


🏁 Script executed:

# Check if any symbols from common.h are used in the file
rg -n 'ROCKETLIB_QSPI_FLASH' include/qspi_flash.h

Repository: waterloo-rocketry/rocketlib

Length of output: 176


🏁 Script executed:

# Verify C preprocessor identifier syntax rules
grep -n '.' include/qspi_flash.h | head -5

Repository: waterloo-rocketry/rocketlib

Length of output: 204


🏁 Script executed:

# Verify C preprocessor standard - identifiers must match pattern [a-zA-Z_][a-zA-Z0-9_]*
# The actual error these lines would cause
python3 << 'EOF'
import re

# C preprocessor identifier pattern (from C standard)
valid_identifier = r'^[a-zA-Z_][a-zA-Z0-9_]*$'

test_cases = [
    "ROCKETLIB_QSPI_FLASH.H",     # Line 1 ifndef token
    "ROCKETLIB_QSPI_FLASH",        # Line 2 define token
    ".H",                          # Line 2 second token
    "ROCKETLIB_QSPI_FLASH_H",      # Proposed fix
]

for token in test_cases:
    is_valid = bool(re.match(valid_identifier, token))
    status = "✓ VALID" if is_valid else "✗ INVALID"
    print(f"{status:12} : {token}")
EOF

Repository: waterloo-rocketry/rocketlib

Length of output: 200


Fix invalid include guard macros—build blocker.

Preprocessor identifiers must contain only alphanumeric characters and underscores. Lines 1–2 contain invalid dots and whitespace that prevent compilation.

🔧 Proposed fix
-#ifndef ROCKETLIB_QSPI_FLASH.H
-#define ROCKETLIB_QSPI_FLASH .H
+#ifndef ROCKETLIB_QSPI_FLASH_H
+#define ROCKETLIB_QSPI_FLASH_H
@@
-#endif /* ROCKETLIB_QSPI_FLASH.H */
+#endif /* ROCKETLIB_QSPI_FLASH_H */

Also applies to: 17–17

🧰 Tools
🪛 GitHub Actions: C Lint Check

[error] 1-1: extra tokens at end of #ifndef directive

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@include/qspi_flash.h` around lines 1 - 2, The include guard identifiers are
invalid (contain dots/space); replace the malformed macros
ROCKETLIB_QSPI_FLASH.H and ROCKETLIB_QSPI_FLASH .H with a valid identifier (for
example ROCKETLIB_QSPI_FLASH_H), updating the `#ifndef` and `#define` lines and the
corresponding `#endif` comment (the symbol referenced at the end of the header) so
they all match the new valid macro name.


#include <stdbool.h>
#include <stdint.h>

#include "common.h"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Remove unused common.h include to satisfy lint.

Line 7 is flagged as unused in CI. If no symbols are consumed from common.h, remove it for now.

🔧 Proposed fix
-#include "common.h"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#include "common.h"
🧰 Tools
🪛 GitHub Actions: C Lint Check

[error] 7-7: Included header 'common.h' is not used directly

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@include/qspi_flash.h` at line 7, Remove the unused `#include` "common.h" from
include/qspi_flash.h to satisfy lint; locate the include directive in the header
(the line with `#include` "common.h") and delete it, or if any symbols from
common.h are actually required by declarations in qspi_flash.h (e.g.,
types/macros used by functions like qspi_init, qspi_read, qspi_write), replace
the include with the minimal forward declarations or include the specific header
that provides those symbols instead of common.h.


#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif

#endif /* ROCKETLIB_QSPI_FLASH.H */
128 changes: 128 additions & 0 deletions stm32h7/mx25l25645g.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#include "mx25l25645g_defs.h"
#include "stm32h7xx_hal.h"

QSPI_HandleTypeDef hqspi;
static uint32_t Timeout = 100;

static const QSPI_InitTypeDef qspi_init_cfg = {
.ClockPrescaler = 4,
.FifoThreshold = 4,
.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE,
.FlashSize = 24, // MX25L25645G = 32MB
.ChipSelectHighTime = QSPI_CS_HIGH_TIME_2_CYCLE,
.ClockMode = QSPI_CLOCK_MODE_0,
.FlashID = QSPI_FLASH_ID_1,
.DualFlash = QSPI_DUALFLASH_DISABLE,
};

void MX_QUADSPI_Init(void) {
hqspi.Instance = QUADSPI;
hqspi.Init = qspi_init_cfg;
if (HAL_QSPI_Init(&hqspi) != HAL_OK) {
Error_Handler();
}
}

// Normal SPI command for flash
const QSPI_CommandTypeDef CMD_BASE = {.Instruction = 0x0;
// .Address = 0x014;
// .AlternateBytes = 0x0;
// .AlternateBytesSize = QSPI_ALTERNATE_BYTES_8_BITS;
.DummyCycles = 0;
.InstructionMode = QSPI_INSTRUCTION_1_LINE;
.AddressMode = QSPI_ADDRESS_NONE;
.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
.DataMode = QSPI_DATA_NONE;
// .NbData = 0x0;
.DdrMode = QSPI_DDR_MODE_DISABLE;
// .DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
}
;
Comment on lines +27 to +41
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

cat -n stm32h7/mx25l25645g.c | head -70

Repository: waterloo-rocketry/rocketlib

Length of output: 2527


🏁 Script executed:

# Check if there's a build system or makefile
fd -type f '(Makefile|CMakeLists\.txt|build\.sh)' . --max-results 5

Repository: waterloo-rocketry/rocketlib

Length of output: 241


🏁 Script executed:

fd -type f -name 'Makefile' . && \
fd -type f -name 'CMakeLists.txt' . && \
fd -type f -name 'build.sh' .

Repository: waterloo-rocketry/rocketlib

Length of output: 241


🏁 Script executed:

find . -maxdepth 2 -name 'Makefile' -o -name 'CMakeLists.txt' -o -name 'build.sh' 2>/dev/null

Repository: waterloo-rocketry/rocketlib

Length of output: 87


🏁 Script executed:

# Check the repository structure
ls -la stm32h7/

Repository: waterloo-rocketry/rocketlib

Length of output: 386


🏁 Script executed:

# Verify the complete context of the initializers
cat -n stm32h7/mx25l25645g.c | sed -n '25,65p'

Repository: waterloo-rocketry/rocketlib

Length of output: 1626


Fix designated-initializer syntax in command templates (compilation blocker).

Lines 27 and 44 start designated initializers but use ; between fields. In C, initializer fields must be comma-separated.

🔧 Proposed fix
-const QSPI_CommandTypeDef CMD_BASE = {.Instruction = 0x0;
+const QSPI_CommandTypeDef CMD_BASE = {
+	.Instruction = 0x0,
 // .Address = 0x014;
 // .AlternateBytes = 0x0;
 // .AlternateBytesSize = QSPI_ALTERNATE_BYTES_8_BITS;
-.DummyCycles = 0;
-.InstructionMode = QSPI_INSTRUCTION_1_LINE;
-.AddressMode = QSPI_ADDRESS_NONE;
-.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
-.DataMode = QSPI_DATA_NONE;
+	.DummyCycles = 0,
+	.InstructionMode = QSPI_INSTRUCTION_1_LINE,
+	.AddressMode = QSPI_ADDRESS_NONE,
+	.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE,
+	.DataMode = QSPI_DATA_NONE,
 // .NbData = 0x0;
-.DdrMode = QSPI_DDR_MODE_DISABLE;
+	.DdrMode = QSPI_DDR_MODE_DISABLE,
 // .DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
-.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
-}
-;
+	.SIOOMode = QSPI_SIOO_INST_EVERY_CMD,
+};

-QSPI_CommandTypeDef CMD_BASE_QSPI = {.Instruction = 0x0;
+QSPI_CommandTypeDef CMD_BASE_QSPI = {
+	.Instruction = 0x0,
 // .Address = 0x014;
 // .AlternateBytes = 0x0;
 // .AddressSize = QSPI_ADDRESS_8_BITS;
 .AlternateBytesSize =
-	QSPI_ALTERNATE_BYTES_8_BITS; // may need to change to QSPI_ADDRESS_24_BITS or 32
-.DummyCycles = 0; // was 8
-.InstructionMode = QSPI_INSTRUCTION_4_LINES;
-.AddressMode = QSPI_ADDRESS_NONE;
-.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
-.DataMode = QSPI_DATA_NONE;
-.NbData = 0;
-.DdrMode = QSPI_DDR_MODE_DISABLE;
-.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
-.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
-}
-;
+	QSPI_ALTERNATE_BYTES_8_BITS, // may need to change to QSPI_ADDRESS_24_BITS or 32
+	.DummyCycles = 0, // was 8
+	.InstructionMode = QSPI_INSTRUCTION_4_LINES,
+	.AddressMode = QSPI_ADDRESS_NONE,
+	.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE,
+	.DataMode = QSPI_DATA_NONE,
+	.NbData = 0,
+	.DdrMode = QSPI_DDR_MODE_DISABLE,
+	.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY,
+	.SIOOMode = QSPI_SIOO_INST_EVERY_CMD,
+};
🧰 Tools
🪛 Cppcheck (2.19.0)

[error] 31-31: syntax error

(syntaxError)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@stm32h7/mx25l25645g.c` around lines 27 - 41, The CMD_BASE QSPI_CommandTypeDef
initializer uses semicolons between fields which is invalid C; replace each ';'
between designated initializer entries with commas and ensure the struct
initializer uses comma-separated fields (and include a trailing comma before the
closing brace) so the CMD_BASE definition and any similar command templates
compile correctly.


// Quad SPI command for flash
QSPI_CommandTypeDef CMD_BASE_QSPI = {.Instruction = 0x0;
// .Address = 0x014;
// .AlternateBytes = 0x0;
// .AddressSize = QSPI_ADDRESS_8_BITS;
.AlternateBytesSize =
QSPI_ALTERNATE_BYTES_8_BITS; // may need to change to QSPI_ADDRESS_24_BITS or 32
.DummyCycles = 0; // was 8
.InstructionMode = QSPI_INSTRUCTION_4_LINES;
.AddressMode = QSPI_ADDRESS_NONE;
.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
.DataMode = QSPI_DATA_NONE;
.NbData = 0;
.DdrMode = QSPI_DDR_MODE_DISABLE;
.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
}
;

static HAL_StatusTypeDef mx25l_exit_qpi(void) {
QSPI_CommandTypeDef cmd = CMD_BASE_QSPI;
cmd.Instruction = MX_CMD_RSTQIO; // 0xF5
cmd.DataMode = QSPI_DATA_NONE;
cmd.NbData = 0;
return HAL_QSPI_Command(&hqspi, &cmd, Timeout);
}

// Enable QSPI mode on the flash
HAL_StatusTypeDef mx25l_enter_qpi(void) {
QSPI_CommandTypeDef cmd = CMD_BASE;
cmd.Instruction = MX_CMD_EQIO;
cmd.DataMode = QSPI_DATA_NONE;
cmd.NbData = 0;
return HAL_QSPI_Command(&hqspi, &cmd, Timeout);
}

// static HAL_StatusTypeDef qspi_write_enable(void) {
// QSPI_CommandTypeDef cmd = CMD_BASE_QSPI;
// cmd.Instruction = MX_CMD_WREN;
// cmd.DataMode = QSPI_DATA_NONE;
// cmd.NbData = 0;

// return HAL_QSPI_Command(&hqspi, &cmd, Timeout);
// }

// static HAL_StatusTypeDef qspi_mx25l_wait_wip0(void) {
// // Command: Read Status Register (RDSR)
// QSPI_CommandTypeDef cmd = {0};
// cmd.InstructionMode = QSPI_INSTRUCTION_1_LINE;
// cmd.Instruction = MX_CMD_RDSR;
// cmd.AddressMode = QSPI_ADDRESS_NONE;
// cmd.DataMode = QSPI_DATA_1_LINE;
// cmd.NbData = 1;
// cmd.DummyCycles = 0;
// cmd.DdrMode = QSPI_DDR_MODE_DISABLE;
// cmd.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;

// // Polling config: wait until WIP=0
// QSPI_AutoPollingTypeDef cfg = {0};
// cfg.Match = 0x00; // WIP must become 0
// cfg.Mask = 0x01; // Check only bit0
// cfg.MatchMode = QSPI_MATCH_MODE_AND;
// cfg.StatusBytesSize = 1;
// cfg.Interval = 0x10;
// cfg.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE;

// return HAL_QSPI_AutoPolling(&hqspi, &cmd, &cfg, Timeout);
// }

int main(void) {
HAL_Init();
SystemClock_Config();

// Initialize the QSPI MSP
MX_GPIO_Init();

// Initialize the QSPI mode with 1 instruction line, CMD_BASE
MX_QUADSPI_Init();

// Enable QPI mode on flash
mx25l_enter_qpi();

Comment on lines +122 to +124
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the exact code at lines 122-124
cat -n stm32h7/mx25l25645g.c | sed -n '120,130p'

Repository: waterloo-rocketry/rocketlib

Length of output: 302


🏁 Script executed:

# Search for mx25l_enter_qpi function definition to understand its return type
rg -n 'mx25l_enter_qpi' stm32h7/mx25l25645g.c -A 5

Repository: waterloo-rocketry/rocketlib

Length of output: 443


🏁 Script executed:

# Check for HAL_OK usage in the file to understand the error handling pattern
rg -n 'HAL_OK' stm32h7/mx25l25645g.c

Repository: waterloo-rocketry/rocketlib

Length of output: 113


🏁 Script executed:

# Look for Error_Handler usage in the file
rg -n 'Error_Handler' stm32h7/mx25l25645g.c -B 2 -A 1

Repository: waterloo-rocketry/rocketlib

Length of output: 173


Check return status of mx25l_enter_qpi() before proceeding.

Line 123 ignores the return value of mx25l_enter_qpi(). The function returns HAL_StatusTypeDef, and if it fails, the flash may not enter QPI mode correctly while initialization continues into the infinite loop. This is inconsistent with the error handling pattern used elsewhere in the file (e.g., line 21).

🔧 Proposed fix
 	// Enable QPI mode on flash
-	mx25l_enter_qpi();
+	if (mx25l_enter_qpi() != HAL_OK) {
+		Error_Handler();
+	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Enable QPI mode on flash
mx25l_enter_qpi();
// Enable QPI mode on flash
if (mx25l_enter_qpi() != HAL_OK) {
Error_Handler();
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@stm32h7/mx25l25645g.c` around lines 122 - 124, mx25l_enter_qpi()'s return
value must be checked and handled like other HAL calls; update the code that
currently calls mx25l_enter_qpi() to capture its HAL_StatusTypeDef result and if
it is not HAL_OK, call the same error path used elsewhere (e.g., Error_Handler()
or the existing flash init failure handling) or return the error to the caller;
specifically modify the call to mx25l_enter_qpi() and add a HAL_OK check and
appropriate error handling to avoid continuing initialization when QPI entry
fails.

// From now on instruction becomes 4 lines since qspi is enabled, QSPI_CMD_BASE

while (1) {}
}
Comment on lines +112 to +128
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

rg -nP --type=c --type=cpp '\bint\s+main\s*\('

Repository: waterloo-rocketry/rocketlib

Length of output: 171


🏁 Script executed:

# Check the repository structure and file organization
git ls-files | head -30

Repository: waterloo-rocketry/rocketlib

Length of output: 696


🏁 Script executed:

# Look at the context around stm32h7/mx25l25645g.c to understand what this file is
fd -type f -name "*.c" -o -name "*.h" | grep -E "(stm32h7|mx25l)" | head -20

Repository: waterloo-rocketry/rocketlib

Length of output: 241


🏁 Script executed:

head -50 stm32h7/mx25l25645g.c

Repository: waterloo-rocketry/rocketlib

Length of output: 1479


🏁 Script executed:

cat include/mx25l25645g.h

Repository: waterloo-rocketry/rocketlib

Length of output: 241


Remove main() from this driver module.

Line 112 introduces a second main() symbol; a duplicate exists at tests/rockettest.cpp:9. Driver modules must not define entry points—they should export functions to be called from an application's main(). This will cause a linker error.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@stm32h7/mx25l25645g.c` around lines 112 - 128, This driver defines a second
program entry point `main()` which must be removed; delete the `main()` function
and instead expose/init functions from this module (keep `mx25l_enter_qpi()`,
`MX_QUADSPI_Init()`, `MX_GPIO_Init()`, etc.) so the application/test `main()`
can call them; ensure any initialization sequence (HAL_Init/SystemClock_Config)
is either removed or wrapped in a clearly named function (e.g.,
`mx25l_driver_init()`) that the application calls, and update or add header
declarations for the exported init functions so no `main` symbol remains in this
driver.

118 changes: 118 additions & 0 deletions stm32h7/mx25l25645g_defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#ifndef ROCKETLIB_MX25l25645G_DEFS_H
#define ROCKETLIB_MX25l25645G_DEFS_H

#include <stdbool.h>
#include <stdint.h>

#include "common.h"

typedef enum {

// ============================================================
// Read/Write Array Commands (3-Byte Address)
// ============================================================

MX_CMD_READ = 0x03, // Normal Read
MX_CMD_FAST_READ = 0x0B, // Fast Read (requires dummy cycles)

MX_CMD_DREAD = 0x3B, // Dual Output Fast Read
MX_CMD_2READ = 0xBB, // Dual I/O Fast Read

MX_CMD_QREAD = 0x6B, // Quad Output Fast Read
MX_CMD_4READ = 0xEB, // Quad I/O Fast Read

MX_CMD_4DTRD = 0xED, // Quad I/O DDR Read (DTR)

MX_CMD_PP = 0x02, // Page Program
MX_CMD_4PP = 0x38, // Quad Page Program

MX_CMD_SE = 0x20, // Sector Erase (4KB)
MX_CMD_BE32K = 0x52, // Block Erase (32KB)
MX_CMD_BE = 0xD8, // Block Erase (64KB)

MX_CMD_CE = 0xC7, // Chip Erase (also possible: 0x60)

// ============================================================
// Read/Write Array Commands (4-Byte Address Command Set)
// ============================================================

MX_CMD_READ4B = 0x13, // Normal Read (4-byte address)
MX_CMD_FAST_READ4B = 0x0C, // Fast Read (4-byte address)

MX_CMD_DREAD4B = 0x3C, // Dual Output Fast Read (4B)
MX_CMD_2READ4B = 0xBC, // Dual I/O Fast Read (4B)

MX_CMD_QREAD4B = 0x6C, // Quad Output Fast Read (4B)
MX_CMD_4READ4B = 0xEC, // Quad I/O Fast Read (4B)

MX_CMD_4DTRD4B = 0xEE, // Quad I/O DDR Read (4B)

MX_CMD_PP4B = 0x12, // Page Program (4B)
MX_CMD_4PP4B = 0x3E, // Quad Page Program (4B)

MX_CMD_SE4B = 0x21, // Sector Erase (4KB, 4B)
MX_CMD_BE32K4B = 0x5C, // Block Erase (32KB, 4B)
MX_CMD_BE4B = 0xDC, // Block Erase (64KB, 4B)

// ============================================================
// Register / Setting Commands
// ============================================================

MX_CMD_WREN = 0x06, // Write Enable
MX_CMD_WRDI = 0x04, // Write Disable

MX_CMD_RDSR = 0x05, // Read Status Register
MX_CMD_WRSR = 0x01, // Write Status + Configuration Register

MX_CMD_RDCR = 0x15, // Read Configuration Register

MX_CMD_RDEAR = 0xC8, // Read Extended Address Register
MX_CMD_WREAR = 0xC5, // Write Extended Address Register

MX_CMD_WPSEL = 0x68, // Write Protection Selection

MX_CMD_EQIO = 0x35, // Enable QPI Mode
MX_CMD_RSTQIO = 0xF5, // Reset / Exit QPI Mode

MX_CMD_EN4B = 0xB7, // Enter 4-byte Address Mode
MX_CMD_EX4B = 0xE9, // Exit 4-byte Address Mode

MX_CMD_PGM_ERS_SUSPEND = 0xB0, // Program/Erase Suspend
MX_CMD_PGM_ERS_RESUME = 0x30, // Program/Erase Resume

MX_CMD_DP = 0xB9, // Deep Power Down
MX_CMD_RDP = 0xAB, // Release from Deep Power Down

MX_CMD_SBL = 0xC0, // Set Burst Length

// ============================================================
// ID / Security Commands
// ============================================================

MX_CMD_RDID = 0x9F, // Read JEDEC ID

MX_CMD_RES = 0xAB, // Read Electronic ID (Legacy)

MX_CMD_REMS = 0x90, // Read Manufacturer / Device ID

MX_CMD_ENSO = 0xB1, // Enter Secured OTP Mode
MX_CMD_EXSO = 0xC1, // Exit Secured OTP Mode

MX_CMD_RDSCUR = 0x2B, // Read Security Register
MX_CMD_WRSCUR = 0x2F, // Write Security Register

MX_CMD_RDDPB = 0xE0, // Read DPB (Dynamic Protection Bits)
MX_CMD_WRDPB = 0xE1, // Write DPB

MX_CMD_RDECC = 0x18, // Read ECC Status

// ============================================================
// Reset Commands
// ============================================================

MX_CMD_RSTEN = 0x66, // Reset Enable
MX_CMD_RST = 0x99, // Reset Memory Device

} command_t;

#endif /* ROCKETLIB_MX25l25645G_DEFS_H */
Loading