Skip to content

Conversation

@ghnotgood
Copy link
Contributor

Summary

BARE 1 is a simple binary representation for structured application data.

cbare 2, the BARE implementation ported by this commit, is an I/O agnostic C implementation of the BARE message encoding.

Impact

Developers can

#include <cbare.h>

and then use cbare API to serialize data.

Testing

I have built NuttX with and without relevant configuration options enabled

CONFIG_NETUTILS_BARE=y
CONFIG_NETUTILS_BARE_TEST=y

I have run

nsh> baretest
nsh> echo $?
0

@simbit18
Copy link
Contributor

simbit18 commented Jan 21, 2026

@ghnotgood necessary to add to Kconfig

depends on ALLOW_MIT_COMPONENTS

https://git.sr.ht/~fsx/cbare/tree/main/item/LICENSE

as for cwebsocket

https://github.com/apache/nuttx-apps/blob/master/netutils/cwebsocket/Kconfig

Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

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

@ghnotgood please include a Documentation about it into nuttx/Documentation/

@ghnotgood
Copy link
Contributor Author

@simbit18 thanks, I have updated the PR.

@ghnotgood
Copy link
Contributor Author

@acassis the PR is already here apache/nuttx#18082 let me know if I need to write more. Thanks.

@acassis
Copy link
Contributor

acassis commented Jan 21, 2026

@acassis the PR is already here apache/nuttx#18082 let me know if I need to write more. Thanks.

Sorry, I missed that there! I just commented there

acassis
acassis previously approved these changes Jan 21, 2026
@ghnotgood
Copy link
Contributor Author

@simbit18 About that MIT license... I did that but I don't know why?

MIT should be ok to use for whatever when the MIT license file stays with the source code. The patch does not remove the LICENSE and therefore it should be ok. Moreover, other applications, like NNG, use MIT license but do not depend on it.

@ghnotgood
Copy link
Contributor Author

I found apache/nuttx#8326 but I don't understand what can go wrong when MIT-licensed code is included in NuttX. Can anyone elaborate?

@simbit18
Copy link
Contributor

@ghnotgood You need to be aware of the licences used; the same applies to BSD, GPL/LGPL, Eclipse Public Licences, etc.
See the kconfig file on NuttX.
https://github.com/apache/nuttx/blob/master/Kconfig#L59-L67

@ghnotgood
Copy link
Contributor Author

ghnotgood commented Jan 21, 2026

@simbit18 why you need that?

or... to maybe ask better... what bad happens when ALLOW_MIT_COMPONENTS does not exist?

@acassis
Copy link
Contributor

acassis commented Jan 21, 2026

@simbit18 why you need that?

or... to maybe ask better... what bad happens when ALLOW_MIT_COMPONENTS does not exist?

@ghnotgood if the user don't enable CONFIG_ALLOW_MIT_COMPONENTS then the BARE will now show up and will not be compiled. It protects users that want to have final firmware only containing Apache code (for patent protections, etc)

@ghnotgood
Copy link
Contributor Author

@acassis so you are saying that when developer builds NuttX with MIT-licensed code the resulting firmware looses patent protections of Apache license?

@acassis
Copy link
Contributor

acassis commented Jan 21, 2026

@acassis so you are saying that when developer builds NuttX with MIT-licensed code the resulting firmware looses patent protections of Apache license?

no, but imagine if someone added MIT code that has a patent hidden behind it (sometimes they don't tell you), if that code is attached to NuttX and the firmware firmware has it, the Apache "protection" was lost!

@ghnotgood
Copy link
Contributor Author

Thank you, I understand now. So the problem is MIT-licensed code implementing patent-protected ideas.

I did a bit of parsing to find out the state of Apache protection in nuttx-apps. Not so good, to be honest:

system/telnet                   "NOASSERTION"                
system/zlib                     "NOASSERTION"                
system/argtable3                "NOASSERTION"                
system/libuv                    "MIT"                        
system/flatbuffers              "Apache-2.0"                 
system/adb                      "Apache-2.0"                 
graphics/lvgl                   "MIT"                        
videoutils/x264                 "GPL-2.0"                    
videoutils/openh264             "BSD-2-Clause"               
boot/mcuboot                    "Apache-2.0"                 
industry/scpi                   "BSD-2-Clause"               
benchmarks/coremark-pro         "NOASSERTION"                
benchmarks/dhrystone            null                         
benchmarks/tacle-bench          null                         
benchmarks/fio                  "GPL-2.0"                    
benchmarks/fio                  "GPL-2.0"                    
benchmarks/superpi              null                         
benchmarks/sd_bench             "BSD-3-Clause"  depends  on  ALLOW_BSD_COMPONENTS
benchmarks/tinymembench         "MIT"                        
benchmarks/test-tlb             "GPL-2.0"       depends  on  ALLOW_GPL_COMPONENTS
benchmarks/coremark             "NOASSERTION"                
games/brickmatch                null                         
wireless/wapi                   "BSD-2-Clause"               
wireless/bluetooth              "Apache-2.0"                 
canutils/candump                null                         
canutils/libdronecan            "MIT"                        
canutils/libopencyphal          "MIT"                        
canutils/libopencyphal          "MIT"                        
canutils/libcanutils            null                         
canutils/cansend                null                         
database/sqlite                 "NOASSERTION"                
testing/mm                      "GPL-2.0"                    
testing/mm                      "Apache-2.0"                 
testing/ltp                     "GPL-2.0"                    
testing/cmocka                  "Apache-2.0"                 
testing/unity                   "MIT"                        
testing/drivers                 "BSD-3-Clause"               
testing/ostest                  "Apache-2.0"                 
testing/fff                     "NOASSERTION"                
tee/optee_client                "NOASSERTION"                
inertial/madgwick               "MIT"           depends  on  ALLOW_MIT_COMPONENTS
netutils/libcoap                "NOASSERTION"                
netutils/jsoncpp                "NOASSERTION"                
netutils/wakaama                null            depends  on  ALLOW_ECLIPSE_COMPONENTS
netutils/telnetc                "NOASSERTION"                
netutils/nng                    "MIT"                        
netutils/mdns                   "Unlicense"                  
netutils/cjson                  "MIT"                        
netutils/libwebsockets          "NOASSERTION"                
netutils/mqttc                  "MIT"                        
netutils/xedge                  "GPL-2.0"       depends  on  ALLOW_GPL_COMPONENTS
netutils/xedge                  "NOASSERTION"   depends  on  ALLOW_GPL_COMPONENTS
netutils/libshvc                null                         
netutils/paho_mqtt              "NOASSERTION"                
netutils/cwebsocket             "Apache-2.0"    depends  on  ALLOW_MIT_COMPONENTS
netutils/rtptools               "NOASSERTION"                
netutils/connectedhomeip        "Apache-2.0"                 
netutils/connectedhomeip        null                         
netutils/connectedhomeip        "Apache-2.0"                 
netutils/connectedhomeip        "Apache-2.0"                 
netutils/connectedhomeip        "Apache-2.0"                 
netutils/connectedhomeip        "MIT"                        
math/ruy                        "Apache-2.0"                 
math/libtommath                 "NOASSERTION"                
math/gemmlowp                   "Apache-2.0"                 
math/kissfft                    "NOASSERTION"                
crypto/libsodium                "NOASSERTION"   depends  on  ALLOW_ICS_COMPONENTS
crypto/mbedtls                  null                         
crypto/mbedtls                  "NOASSERTION"                
crypto/tinydtls                 null            depends  on  ALLOW_ECLIPSE_COMPONENTS
crypto/libtomcrypt              "NOASSERTION"                
crypto/libtomcrypt              "NOASSERTION"                
crypto/wolfssl                  null            depends  on  ALLOW_GPL_COMPONENTS
crypto/tinycrypt                "NOASSERTION"                
crypto/openssl_mbedtls_wrapper  "Apache-2.0"                 
audioutils/libmad               "GPL-2.0"                    
include/netutils                "NOASSERTION"                
mlearning/libnnablart           "Apache-2.0"                 
mlearning/darknet               "NOASSERTION"                
mlearning/cmsis                 "Apache-2.0"                 
mlearning/tflite-micro          "Apache-2.0"                 
mlearning/cmsis-nn              "Apache-2.0"                 
interpreters/luamodules         "MIT"                        
interpreters/luamodules         "MIT"                        
interpreters/luamodules         "Apache-2.0"                 
interpreters/luamodules         "MIT"                        
interpreters/duktape            "MIT"                        
interpreters/toywasm            "BSD-2-Clause"               
interpreters/wasm3              "MIT"                        
interpreters/quickjs            "NOASSERTION"                
interpreters/wamr               "Apache-2.0"                 
interpreters/luajit             "NOASSERTION"                
interpreters/lua                null                         
interpreters/python             "NOASSERTION"                
interpreters/mquickjs           "NOASSERTION"                
fsutils/libtinycbor             "MIT"           depends  on  ALLOW_MIT_COMPONENTS
fsutils/inih                    "NOASSERTION"                
sdr/liquid_dsp                  "MIT"                        
examples/xedge_demo             "GPL-2.0"                    
examples/optee_gp               "NOASSERTION"                
examples/tlpi                   "AGPL-3.0"      depends  on  ALLOW_GPL_COMPONENTS
examples/apa102                 "MIT"                        
examples/rust                   null                         

@simbit18
Copy link
Contributor

@ghnotgood Thank you for pointing this out. The licence must be added where necessary.

@acassis @raiden00pl @jerpelea

@simbit18 simbit18 requested review from cederom and linguini1 January 21, 2026 17:44
@raiden00pl
Copy link
Member

license should also be added to the LICENSE file

@simbit18
Copy link
Contributor

In any case, you never get bored on NuttX! :)

BARE is a simple binary representation for structured application data.

cbare, the BARE implementation ported by this commit, is an I/O agnostic
C implementation of the BARE message encoding.

Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
@ghnotgood
Copy link
Contributor Author

@raiden00pl I have updated the nuttx-apps/LICENSE file.

Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
@acassis
Copy link
Contributor

acassis commented Jan 21, 2026

Good work @ghnotgood, some observations/questions:

  1. what do you mean by "NOASSERTION", I noticed that netutils/telnetc for example is "Apache-2.0"
  2. ZLIB is also a standard and known license, I think we need to add ALLOW_ZLIB_COMPONENTS
  3. why Tinydtls is null, and it shows it is already depending on ALLOW_ECLIPSE_COMPONENTS?

I think we need to implement some kind of LICENSE tracking, like I suggested in apache/nuttx#8326

Something like this:

enum {
    NX_LIC_APACHE_2_0 = (1 << 0),
    NX_LIC_BSD_3_CLAUSE = (1 << 1),
    NX_LIC_MIT = (1 << 2),
    NX_LIC_GPL_V2 = (1 << 3),
    …
};

extern uint32_t g_nx_license_bits;

#define NX_ADD_LICENSE(x) (g_nx_license_bits |= (x))

Or maybe something even better, like a license map to know which program/library added that license, for easy tracking:

// license_map.h

typedef struct {
    const char *module;
    uint32_t license_bit;
    const char *license_str;
} nx_license_map_t;

extern const nx_license_map_t g_license_map[];

const nx_license_map_t g_license_map[] = {
    { "net/ip", NX_LIC_BSD_3_CLAUSE, "BSD-3-Clause" },
    { "fs/fat", NX_LIC_MIT,          "MIT" },
    …
}; //This map should be populated by a simple ADD_LICENSE() macro.

printf("Licenses used:\n");
for (each bit set) print corresponding string

But this option could be disabled for deep embedded microcontrollers, to avoid wasting flash memory (also the license_str don't need to be included for each line, it could be resolved from license_bit).

@ghnotgood @simbit18 @raiden00pl @xiaoxiang781216 what do you think? I can implement it if all here agree that this license tracking is important.

Currenly our only alternative is searching for "SPDX-License-Identifier:" but it is difficult to know which files where used. Remember: not all files compiled by NuttX are used in the final firmware.

@cederom
Copy link
Contributor

cederom commented Jan 21, 2026

Thank you @ghnotgood, this cbare looks interesting :-)

The typo commit should go into a separate PR as it is not related to CBARE and needs commit subject fix right? We may pass it here but subject needs update as noted by ci check :-)

Comment on lines +9 to +25
+#ifndef UNUSED
#define UNUSED(x) (void)(x)
+#endif

enum {
U8SZ = 1,
diff --git i/test/baretest.c w/test/baretest.c
index 1561f4c..9df740f 100644
--- i/test/baretest.c
+++ w/test/baretest.c
@@ -10,7 +10,9 @@
#include "alloc.h"
#include "die.h"

+#ifndef UNUSED
#define UNUSED(x) (void)(x)
+#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this modification is really small and it will not impact the original project, maybe you can consider submitting a PR to them, then we can remove this .patch later ;-)

@raiden00pl
Copy link
Member

@acassis I don't see any point in including license information in the firmware. The firmware doesn't care about licence. It's the user's responsibility to properly manage licenses and complete all licensing formal requirements. The licenses used by firmware should be easily accessible from the configuration, and that's how it is now. Licensing options are disabled by defaul so the user must consciously enable non-apach license and they always appear in defconfig.

@acassis
Copy link
Contributor

acassis commented Jan 21, 2026

@acassis I don't see any point in including license information in the firmware. The firmware doesn't care about licence. It's the user's responsibility to properly manage licenses and complete all licensing formal requirements. The licenses used by firmware should be easily accessible from the configuration, and that's how it is now. Licensing options are disabled by defaul so the user must consciously enable non-apach license and they always appear in defconfig.

True, but in this case we need to do our best to guarantee:

  1. all licensed file (other than Apache 2.0) are behind a CONFIG_ALLOW_XXXXXX_COMPONENTS;
  2. none defconfig submitted to mainline automatically include/set a CONFIG_ALLOW_XXXXXX_COMPONENTS (today WiFi, Bluetooth, etc, depends on it); and/or
  3. After the firmware image is generated we issue a warning saying License X, Y, Z is enabled.

We need to make things explicit to user, because the assumption that licenses are disabled by default is not true because it comes from defconfig and users/companies never pay attention.

Remember the case of the drone company that released a PX4 firmware with memory display commands in the firmware? They never paid attention about these commands present in the nsh> until a user used that command to dump their entire proprietary firmware.

@xiaoxiang781216
Copy link
Contributor

@ghnotgood please fix ci check error:

89b66b23f netutils: Add BARE
../nuttx/tools/checkpatch.sh -c -u -m -g 10873c6b59ce5cc22a3f2b20e1d7617ad04a427a..HEAD
❌ Commit subject missing colon (e.g. 'subsystem: msg')
❌ Missing git commit message
Used config files:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants