Skip to content

Commit 4f5cd7b

Browse files
committed
fix: update nuttx article for external static libraries
Apply some text changes for better reading. Signed-off-by: Filipe Cavalcanti <[email protected]>
1 parent de82822 commit 4f5cd7b

File tree

1 file changed

+16
-9
lines changed
  • content/blog/2025/11/nuttx-external-lib

1 file changed

+16
-9
lines changed

content/blog/2025/11/nuttx-external-lib/index.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ tags: ["NuttX", "Apache", "ESP32", "ESP32-C6", "RISC-V", "cross-compilation", "s
55
showAuthor: false
66
authors:
77
- "filipe-cavalcanti"
8-
summary: "This guide demonstrates how to integrate external libraries into NuttX applications using static libraries and cross-compilation. Learn how to build a library on x86, integrate it into the NuttX simulation environment, and cross-compile for RISC-V targets like the ESP32-C6, all without moving your codebase into the NuttX directory structure."
8+
summary: "This guide demonstrates how to integrate external libraries into NuttX applications using static libraries and cross-compilation. Learn how to build a library on x86, integrate it into the NuttX simulation environment, and cross-compile for RISC-V targets like the ESP32-C6, all without moving your entire codebase into the NuttX directory structure."
99
---
1010

1111
## Introduction
1212

13-
When moving your application to NuttX, you often need to add your existing software stack to the NuttX image. This software may run on a different RTOS or even on an x86 environment, but sometimes it must run on multiple target devices. This article shows how to build NuttX with your custom application without moving your entire stack to the NuttX directory. You use a static library and cross-compilation to achieve this.
13+
When moving your application to NuttX, you may need to add your existing codebase to the NuttX build environment. That is a common scenario where the user application does not interact with hardware (such as data processing and analysis) but must run on the target devices. Those applications are usually tested on a x86 computer and adapted to run on a RTOS.
1414

15-
This article is divided into three parts. The first part introduces and builds the sample library on x86. Then, a second part decribes how to add the library to the NuttX simulation environment and finally, the last part cross-compiles to RISC-V and runs the example on the ESP32-C6.
15+
This article shows how to build NuttX with your custom application without moving your entire stack to the NuttX directory. You use a static library and cross-compilation to achieve this.
16+
17+
This article is divided into three parts. The first part introduces and builds the sample library on x86. Then, a second part decribes how to add the library to the NuttX simulation environment. The third part cross-compiles to RISC-V and runs the example on the ESP32-C6. Finally, the fourth part concludes the article.
1618

1719
## Using an example library
1820

@@ -34,15 +36,19 @@ The reference project is available in [this repository](https://github.com/fdcav
3436
The `hex-converter` library exposes one single function called `hex_to_rgb`. The user provides a pointer to a string representing the hex color and a pointer
3537
to an array where the R, G, and B values are copied. It is a simple application but very useful as an example.
3638

37-
Clone the repository and build it according to the steps in the README file to produce the static library. To confirm that everything works, run the provided `main` example program. This program accepts a hexadecimal color string as input.
39+
Now, we should use the library on our x86 machine and see how it operates.
40+
41+
1. Clone the repository
42+
2. Build the library according to the steps in the README file
43+
3. Execute the provided `main` example program:
3844

3945
```bash
4046
$ ./main "#1A2B3C"
4147
Input: #1A2B3C
4248
RGB: (26, 43, 60)
4349
```
4450

45-
At this point, the directory should contain a static library called `libhex_to_rgb.a` that will be added to the NuttX build system.
51+
At this point, the directory should contain a static library called `libhex_to_rgb.a`.
4652

4753
## Testing on NuttX Simulation
4854

@@ -53,8 +59,9 @@ The simplest way to test this library on NuttX is to modify the ready-to-use Hel
5359

5460
With your NuttX environment ready, follow these steps:
5561

56-
1. Copy `libhex_to_rgb.a` from the hex-converter repository to `apps/examples/hello` (the Hello World example directory).
57-
2. In `apps/hello/Make.defs`, add the hex library, library path, and include path.
62+
1. Clone the example repository and build `libhex_to_rgb.a` as discussed in `Using an example library`
63+
2. Copy `libhex_to_rgb.a` to `apps/examples/hello` (the Hello World example directory)
64+
3. In `apps/hello/Make.defs`, add the hex library, library path, and include path
5865

5966
The Make.defs file should look like this:
6067
```
@@ -134,7 +141,7 @@ Success! We can compile our library externally, link it to a NuttX application,
134141
## Using the library on ESP32C6
135142
136143
Now that simulation works, we must look into a real use case that requires the same code to work on hardware.
137-
For this, we must compile the library to be supported on our RISC-V target.
144+
For this, we should recompile the library to be supported on our RISC-V target.
138145
139146
### Cross-compilation
140147
@@ -190,7 +197,7 @@ This article demonstrates how to integrate external libraries into NuttX applica
190197
191198
The static library approach offers several advantages. You can develop and test your code on an x86 machine without flashing the target device. The same library works across different architectures with minimal changes, requiring only a recompilation step. This workflow saves development time and simplifies the porting process.
192199
193-
By following these steps, you can add existing software stacks to NuttX without moving your entire codebase into the NuttX directory structure. This approach maintains separation between your application code and the RTOS, making maintenance and updates easier.
200+
By following these steps, you can add existing applications to NuttX without moving your entire codebase into the NuttX directory structure. This approach maintains separation between your application code and the RTOS, making maintenance and updates easier.
194201
195202
## Related Resources
196203

0 commit comments

Comments
 (0)