Page 1 of 1

fatal error: alloca.h: No such file or directory

Posted: 2024-06-13 12:31
by gkirill
Hello!
I know that the question is stupid, but I can’t find where to declare the path to the headers that need to be connected to the project.
I successfully ran the test script from the fifth point at this link https://wiki.luckfox.com/Luckfox-Pico/Luckfox-Pico-SDK, when I try to connect other headers, an error occurs:

Code: Select all

fatal error: alloca.h: No such file or directory
 #include <alloca.h>
          ^~~~~~~~~~
Where should I write the path to the headers connected to the project so as not to encounter this error?

Re: fatal error: alloca.h: No such file or directory

Posted: 2024-06-14 1:32
by Eng38
Hello,

In Linux kernel module development, alloca.h and alloca functions are usually not used, because these are dynamic memory allocation functions designed for user space. In kernel space, memory management functions provided by the kernel are usually used, such as kmalloc and kfree.

Re: fatal error: alloca.h: No such file or directory

Posted: 2024-06-14 3:58
by gkirill
Eng38 wrote: 2024-06-14 1:32 Hello,

In Linux kernel module development, alloca.h and alloca functions are usually not used, because these are dynamic memory allocation functions designed for user space. In kernel space, memory management functions provided by the kernel are usually used, such as kmalloc and kfree.
Hello, Eng38!
what if I want to use "assert.h" in my project?

Re: fatal error: alloca.h: No such file or directory

Posted: 2024-06-14 6:19
by Eng38
Since the example is a Linux kernel module code, the alloca.h header file cannot be used. You can use the alloca.h header file in a non-kernel module application and compile it using a cross-compilation tool, as shown in the following figure:
企业微信截图_1718345147386.png

Re: fatal error: alloca.h: No such file or directory

Posted: 2024-06-14 12:44
by gkirill
Eng38 wrote: 2024-06-14 6:19 Since the example is a Linux kernel module code, the alloca.h header file cannot be used. You can use the alloca.h header file in a non-kernel module application and compile it using a cross-compilation tool, as shown in the following figure:企业微信截图_1718345147386.png
Thank you for the clarification, Eng38!
I'll describe the situation from the very beginning, I have headers in the project that need to be connected:

Code: Select all

#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <pthread.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/poll.h>
#include <time.h>
#include <unistd.h>

RK_BOOL 				multi_sensor = RK_FALSE;
const char  			*iq_dir 	 = "/etc/iqfiles";
rk_aiq_working_mode_t   hdr_mode 	 = RK_AIQ_WORKING_MODE_NORMAL;

int width 		 = 720;
int height 		 = 480;
uint8_t GOP		 = 20;
uint16_t BitRate = 10 *1024;

static int helloworld_init(void)
{
	SAMPLE_COMM_ISP_Init(0, hdr_mode, multi_sensor, iq_dir);
	SAMPLE_COMM_ISP_Run(CamID);
	
	// rkmpi init
	if (RK_MPI_SYS_Init() != RK_SUCCESS) 
	{
		RK_LOGE("rk mpi sys init fail!");
		return 0;
	}
	
	// vi init
	vi_dev_init();
	vi_chn_init(0, width, height);
	
	// VPSS Init
	vpss_init(0, width, height);
	
	
	// VENC Init
	RK_CODEC_ID_E enCodecType = RK_VIDEO_ID_AVC;
	venc_init(0, width, height, enCodecType);
	
	vi_chn_attr.enPixelFormat = RK_FMT_YUV420SP; // VI Chn
	stGrpVpssAttr.enPixelFormat = RK_FMT_YUV420SP; // VPSS Group
	
	stAttr.stRcAttr.enRcMode 			 = VENC_RC_MODE_H264CBR;
	stAttr.stRcAttr.stH264Cbr.u32BitRate = BitRate;
	stAttr.stRcAttr.stH264Cbr.u32Gop 	 = GOP;
}

static void helloworld_exit(void)
{
	printk("helloworld bye\n");
}

module_init(helloworld_init);
module_exit(helloworld_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Luckfox");
MODULE_VERSION("V1.0");
Following the example from the fifth point at the link https://wiki.luckfox.com/Luckfox-Pico/Luckfox-Pico-SDK I call the commands:

Code: Select all

export ARCH=arm

export CROSS_COMPILE=/home/luckfox/Luckfox-Pico/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-

make
And I get the following error:

Code: Select all

kirill@GLININ24:~/rockchip/luckfox-pico/Load.ko-driver$ export ARCH=arm
kirill@GLININ24:~/rockchip/luckfox-pico/Load.ko-driver$ export CROSS_COMPILE=/home/kirill/rockchip/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
kirill@GLININ24:~/rockchip/luckfox-pico/Load.ko-driver$ make
make -C /home/kirill/rockchip/luckfox-pico/sysdrv/source/kernel M=/home/kirill/rockchip/luckfox-pico/Load.ko-driver modules
make[1]: Entering directory '/home/kirill/rockchip/luckfox-pico/sysdrv/source/kernel'
  CC [M]  /home/kirill/rockchip/luckfox-pico/Load.ko-driver/rockchip_recorder.o
/home/kirill/rockchip/luckfox-pico/Load.ko-driver/rockchip_recorder.c:1:10: fatal error: assert.h: No such file or directory
 #include <assert.h>
          ^~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:273: /home/kirill/rockchip/luckfox-pico/Load.ko-driver/rockchip_recorder.o] Error 1
make[1]: *** [Makefile:1917: /home/kirill/rockchip/luckfox-pico/Load.ko-driver] Error 2
make[1]: Leaving directory '/home/kirill/rockchip/luckfox-pico/sysdrv/source/kernel'
make: *** [Makefile:5: all] Error 2
If I try to build the project using your path, I get a bunch of error messages:

Code: Select all

kirill@GLININ24:~/rockchip/luckfox-pico/Load.ko-driver$ arm-rockchip830-linux-uclibcgnueabihf-gcc rockchip_recorder.c
rockchip_recorder.c:17:1: error: unknown type name 'RK_BOOL'
 RK_BOOL     multi_sensor = RK_FALSE;
 ^~~~~~~
rockchip_recorder.c:17:28: error: 'RK_FALSE' undeclared here (not in a function)
 RK_BOOL     multi_sensor = RK_FALSE;
                            ^~~~~~~~
rockchip_recorder.c:19:1: error: unknown type name 'rk_aiq_working_mode_t'
 rk_aiq_working_mode_t   hdr_mode   = RK_AIQ_WORKING_MODE_NORMAL;
 ^~~~~~~~~~~~~~~~~~~~~
rockchip_recorder.c:19:38: error: 'RK_AIQ_WORKING_MODE_NORMAL' undeclared here (not in a function)
 rk_aiq_working_mode_t   hdr_mode   = RK_AIQ_WORKING_MODE_NORMAL;
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
rockchip_recorder.c:23:1: error: unknown type name 'uint8_t'; did you mean 'u_int8_t'?
 uint8_t GOP   = 20;
 ^~~~~~~
 u_int8_t
rockchip_recorder.c:24:1: error: unknown type name 'uint16_t'; did you mean 'u_int16_t'?
 uint16_t BitRate = 10 *1024;
 ^~~~~~~~
 u_int16_t
rockchip_recorder.c: In function 'helloworld_init':
rockchip_recorder.c:28:2: warning: implicit declaration of function 'SAMPLE_COMM_ISP_Init' [-Wimplicit-function-declaration]
  SAMPLE_COMM_ISP_Init(0, hdr_mode, multi_sensor, iq_dir);
  ^~~~~~~~~~~~~~~~~~~~
rockchip_recorder.c:29:2: warning: implicit declaration of function 'SAMPLE_COMM_ISP_Run' [-Wimplicit-function-declaration]
  SAMPLE_COMM_ISP_Run(CamID);
  ^~~~~~~~~~~~~~~~~~~
rockchip_recorder.c:29:22: error: 'CamID' undeclared (first use in this function)
  SAMPLE_COMM_ISP_Run(CamID);
                      ^~~~~
rockchip_recorder.c:29:22: note: each undeclared identifier is reported only once for each function it appears in
rockchip_recorder.c:32:6: warning: implicit declaration of function 'RK_MPI_SYS_Init' [-Wimplicit-function-declaration]
  if (RK_MPI_SYS_Init() != RK_SUCCESS)
      ^~~~~~~~~~~~~~~
rockchip_recorder.c:32:27: error: 'RK_SUCCESS' undeclared (first use in this function); did you mean 'EXIT_SUCCESS'?
  if (RK_MPI_SYS_Init() != RK_SUCCESS)
                           ^~~~~~~~~~
                           EXIT_SUCCESS
rockchip_recorder.c:34:3: warning: implicit declaration of function 'RK_LOGE' [-Wimplicit-function-declaration]
   RK_LOGE("rk mpi sys init fail!");
   ^~~~~~~
rockchip_recorder.c:39:2: warning: implicit declaration of function 'vi_dev_init'; did you mean 'gnu_dev_minor'? [-Wimplicit-function-declaration]
  vi_dev_init();
  ^~~~~~~~~~~
  gnu_dev_minor
rockchip_recorder.c:40:2: warning: implicit declaration of function 'vi_chn_init' [-Wimplicit-function-declaration]
  vi_chn_init(0, width, height);
  ^~~~~~~~~~~
rockchip_recorder.c:43:2: warning: implicit declaration of function 'vpss_init'; did you mean 'si_int'? [-Wimplicit-function-declaration]
  vpss_init(0, width, height);
  ^~~~~~~~~
  si_int
rockchip_recorder.c:47:2: error: unknown type name 'RK_CODEC_ID_E'
  RK_CODEC_ID_E enCodecType = RK_VIDEO_ID_AVC;
  ^~~~~~~~~~~~~
rockchip_recorder.c:47:30: error: 'RK_VIDEO_ID_AVC' undeclared (first use in this function)
  RK_CODEC_ID_E enCodecType = RK_VIDEO_ID_AVC;
                              ^~~~~~~~~~~~~~~
rockchip_recorder.c:48:2: warning: implicit declaration of function 'venc_init' [-Wimplicit-function-declaration]
  venc_init(0, width, height, enCodecType);
  ^~~~~~~~~
rockchip_recorder.c:50:2: error: 'vi_chn_attr' undeclared (first use in this function)
  vi_chn_attr.enPixelFormat = RK_FMT_YUV420SP; // VI Chn
  ^~~~~~~~~~~
rockchip_recorder.c:50:30: error: 'RK_FMT_YUV420SP' undeclared (first use in this function)
  vi_chn_attr.enPixelFormat = RK_FMT_YUV420SP; // VI Chn
                              ^~~~~~~~~~~~~~~
rockchip_recorder.c:51:2: error: 'stGrpVpssAttr' undeclared (first use in this function)
  stGrpVpssAttr.enPixelFormat = RK_FMT_YUV420SP; // VPSS Group
  ^~~~~~~~~~~~~
rockchip_recorder.c:53:2: error: 'stAttr' undeclared (first use in this function); did you mean 'strstr'?
  stAttr.stRcAttr.enRcMode     = VENC_RC_MODE_H264CBR;
  ^~~~~~
  strstr
rockchip_recorder.c:53:33: error: 'VENC_RC_MODE_H264CBR' undeclared (first use in this function)
  stAttr.stRcAttr.enRcMode     = VENC_RC_MODE_H264CBR;
                                 ^~~~~~~~~~~~~~~~~~~~
rockchip_recorder.c: In function 'helloworld_exit':
rockchip_recorder.c:60:2: warning: implicit declaration of function 'printk'; did you mean 'printf'? [-Wimplicit-function-declaration]
  printk("helloworld bye\n");
  ^~~~~~
  printf
rockchip_recorder.c: At top level:
rockchip_recorder.c:63:1: warning: data definition has no type or storage class
 module_init(helloworld_init);
 ^~~~~~~~~~~
rockchip_recorder.c:63:1: warning: type defaults to 'int' in declaration of 'module_init' [-Wimplicit-int]
rockchip_recorder.c:63:1: warning: parameter names (without types) in function declaration
rockchip_recorder.c:64:1: warning: data definition has no type or storage class
 module_exit(helloworld_exit);
 ^~~~~~~~~~~
rockchip_recorder.c:64:1: warning: type defaults to 'int' in declaration of 'module_exit' [-Wimplicit-int]
rockchip_recorder.c:64:1: warning: parameter names (without types) in function declaration
rockchip_recorder.c:66:16: error: expected declaration specifiers or '...' before string constant
 MODULE_LICENSE("GPL");
                ^~~~~
rockchip_recorder.c:67:15: error: expected declaration specifiers or '...' before string constant
 MODULE_AUTHOR("Luckfox");
               ^~~~~~~~~
rockchip_recorder.c:68:16: error: expected declaration specifiers or '...' before string constant
 MODULE_VERSION("V1.0");
When I try to add #include <rk_type.h> I also get the message

Code: Select all

rockchip_recorder.c:14:10: fatal error: rk_type.h: No such file or directory
 #include <rk_type.h>
 ^~~~~~~~~~~
 
Now, to add the rk_type.h header, do I need to write the full path to it in the application? Or can I add it somewhere else?
How does assembling a project according to the example on the site (https://wiki.luckfox.com/Luckfox-Pico/Luckfox-Pico-SDK/) differ from the path that you proposed?

Re: fatal error: alloca.h: No such file or directory

Posted: 2024-06-15 2:53
by Eng38
The error message you saw indicates that the assert.h header file cannot be found. This header file is part of the C standard library and is not available in kernel space. If your code is designed for user space, it should not be compiled as a kernel module. Note that the Makefile in the example(https://wiki.luckfox.com/Luckfox-Pico/Luckfox-Pico-SDK/) indicates that it will be compiled as a kernel module, which does not apply to your program.

If you want to write a camera-related program, it is recommended to refer to: https://wiki.luckfox.com/Luckfox-Pico/RKMPI-example

Re: fatal error: alloca.h: No such file or directory

Posted: 2024-08-15 8:09
by wwalker
I just had a similar problem with an rpi pico and assert.h.

I was able to install this package (I'm running Fedora 40, ymmv):

* `arm-none-eabi-newlib`

Re: fatal error: alloca.h: No such file or directory

Posted: 2024-08-15 11:29
by Crocodile
wwalker wrote: 2024-08-15 8:09 I just had a similar problem with an rpi pico and assert.h.

I was able to install this package (I'm running Fedora 40, ymmv):

* `arm-none-eabi-newlib`
Hello, this is the technical forum for Luckfox Pico. While the hardware design of the Luckfox Pico references the pinout design of the RPi Pico for compatibility with external peripherals, there isn't much software compatibility between the two. We recommend setting up a new environment or updating the cross-compilation tools for the RPi Pico before proceeding. Additionally, if you're interested, we welcome you to join the Luckfox Pico community.