fdcavalcanti commented on code in PR #15128: URL: https://github.com/apache/nuttx/pull/15128#discussion_r1881202927
########## Documentation/guides/port_arm_cm4.rst: ########## @@ -0,0 +1,935 @@ +The case of ARM CM4 & cxd32xx @NuttX12.4.0 +========================================== + +Step1 : Add and register the SoC directory +------------------------------------------ + +Create the SoC directory. + +.. code-block:: + + $ touch arch/arm/include/cxd32xx + $ touch arch/arm/src/cxd32xx + +Modify "arch/arm/Kconfig" to register the SoC directory. + +Add "Kconfig" and "Make.defs" for the SoC directory. + +.. code-block:: + + $ touch arch/arm/src/cxd32xx/Kconfig + $ touch arch/arm/src/cxd32xx/Make.defs + +For details about these files, see the PR : https://github.com/apache/nuttx/pull/12441 + +Step2 : Add and register the Board directory +-------------------------------------------- + +There are two ways about adding the Board directory. The one is in-of-tree, another one is out-of-tree. +For details see :doc:`/guides/customboards`. +And if you wanted to add own apps, see :doc:`/guides/customapps`. + +This time, the way of out-of-tree is selected. The directory structure is following : + +.. code-block:: + + apps/ + nuttx/ + out-of-tree/cxd32xx_boards + +Create the board : cb2sdb2 as the board of cxd32xx. + +.. code-block:: + + $ touch out-of-tree/cxd32xx_boards/cb2sdb2/configs/nsh + $ touch out-of-tree/cxd32xx_boards/cb2sdb2/include + $ touch out-of-tree/cxd32xx_boards/cb2sdb2/scripts + $ touch out-of-tree/cxd32xx_boards/cb2sdb2/src + +Add "Kconfig", "defconfig", "Make.defs" and "Makefile". + +.. code-block:: + + $ touch out-of-tree/cxd32xx_boards/cb2sdb2/Kconfig + $ touch out-of-tree/cxd32xx_boards/cb2sdb2/configs/nsh/defconfig + $ touch out-of-tree/cxd32xx_boards/cb2sdb2/scripts/Make.defs + $ touch out-of-tree/cxd32xx_boards/cb2sdb2/src/Makefile + +For details about these files, see :ref:`out-of-tree`. + +Step3 : Configuring +------------------- + +Now you can do configuring by following commands. It is important to confirm these commands are working. + +.. code-block:: + + $ cd nuttx + $ ./tools/configure.sh -l ../out-of-tree/cxd32xx_boards/cb2sdb2/configs/nsh + +And you can do menuconfig by following command. + +.. code-block:: + + $ make menuconfig + +And you can do distclean by following command. + +.. code-block:: + + $ make distclean + +Step4 : Compiling +----------------- + +Try to buid with the implementation of Step1-2, you would face the error as following if you implemented only directory / Kconfig / Make.defs / Makefile / defconfig about Step1-2. + +.. code-block:: + + $ make + Create version.h + LN: platform/board to /home/lassdk/workdir/nuttx1/apps/platform/dummy + In file included from /home/lassdk/workdir/nuttx1/nuttx/include/nuttx/irq.h:37:0, + from /home/lassdk/workdir/nuttx1/nuttx/include/nuttx/sched.h:40, + from /home/lassdk/workdir/nuttx1/nuttx/include/nuttx/arch.h:87, + from ./clock/clock_initialize.c:37: + /home/lassdk/workdir/nuttx1/nuttx/include/arch/irq.h:43:27: fatal error: arch/chip/irq.h: No such file or directory + compilation terminated. + ERROR: arm-none-eabi-gcc failed: 1 + command: arm-none-eabi-gcc -MT ./clock_initialize.o -M '-Wstrict-prototypes' '-Wno-attributes' '-Wno-unknown-pragmas' '-Wno-psabi' '-Os' '-fno-strict-aliasing' '-fomit-frame-pointer' '-fno-common' '-Wall' '-Wshadow' '-Wundef' '-ffunction-sections' '-fdata-sections' '-mlittle-endian' '-march=armv7e-m' '-mtune=cortex-m4' '-mfpu=fpv4-sp-d16' '-mfloat-abi=hard' '-mthumb' '-Wa,-mthumb' '-Wa,-mimplicit-it=always' '-isystem' '/home/lassdk/workdir/nuttx1/nuttx/include' '-D__NuttX__' '-DNDEBUG' '-D__KERNEL__' '-pipe' '-I' '/home/lassdk/workdir/nuttx1/nuttx/sched' ./clock/clock_initialize.c + make[2]: *** [/home/lassdk/workdir/nuttx1/nuttx/tools/Config.mk:230: clock_initialize.ddc] Error 1 + make[1]: *** [Makefile:71: .depend] Error 2 + make: *** [tools/Unix.mk:619: pass2dep] Error 2 + +Try to add "irq.h" with referring to cxd56xx and retry to build. This time, the build system will teach that you have to implement "chip.h" as following. + +.. code-block:: + + $ make + CC: clock/clock_initialize.c In file included from /home/lassdk/workdir/nuttx2/nuttx/include/arch/armv7-m/irq.h:37:0, + from /home/lassdk/workdir/nuttx2/nuttx/include/arch/irq.h:56, + from /home/lassdk/workdir/nuttx2/nuttx/include/nuttx/irq.h:37, + from /home/lassdk/workdir/nuttx2/nuttx/include/nuttx/sched.h:40, + from /home/lassdk/workdir/nuttx2/nuttx/include/nuttx/arch.h:87, + from clock/clock_initialize.c:37: + /home/lassdk/workdir/nuttx2/nuttx/include/arch/armv7-m/nvicpri.h:28:28: fatal error: arch/chip/chip.h: No such file or directory + compilation terminated. + make[1]: *** [Makefile:61: clock_initialize.o] Error 1 + make: *** [tools/LibTargets.mk:65: sched/libsched.a] Error 2 + +Continue this try and error until pass the Compiling. + +Step5 : Linking +--------------- + +After the pass of Compiling, you will get following error. To resolve this error, you have to implement the linker script. + +.. code-block:: + + $ make + make[1]: *** No rule to make target '/home/lassdk/workdir/nuttx1/nuttx/../cxd32xx_boards/cb2sdb2/scripts/cb2sdb2.ld', needed by '/home/lassdk/workdir/nuttx1/nuttx/../cxd32xx_boards/cb2sdb2/scripts/cb2sdb2.ld.tmp'. Stop. + make: *** [tools/Unix.mk:545: nuttx] Error 2 + +Try to add the linker script with referring to some board(cxd56xx, lpc43xx, etc) or :ref:`out-of-tree` and retry to build, the build system will teach that you have to implement some symbols as following. + +.. code-block:: + + $ make + CPP: /home/lassdk/workdir/nuttx1/nuttx/../cxd32xx_boards/cb2sdb2/scripts/cb2sdb2.ld-> /home/lassdk/workdir/nuttx1/nuttx/../boarLD: nuttx + arm-none-eabi-ld: warning: cannot find entry symbol __start; defaulting to 24011000 + /home/lassdk/workdir/nuttx1/nuttx/staging/libarch.a(arm_vectors.o):(.vectors+0x4): undefined reference to `__start' + /home/lassdk/workdir/nuttx1/nuttx/staging/libarch.a(arm_doirq.o): In function `arm_doirq': + arm_doirq.c:(.text.arm_doirq+0x12): undefined reference to `arm_ack_irq' + /home/lassdk/workdir/nuttx1/nuttx/staging/libdrivers.a(syslog_channel.o): In function `syslog_default_putc': + syslog_channel.c:(.text.syslog_default_putc+0x2): undefined reference to `up_putc' + /home/lassdk/workdir/nuttx1/nuttx/staging/libarch.a(arm_nputs.o): In function `up_nputs': + arm_nputs.c:(.text.up_nputs+0x10): undefined reference to `up_putc' + make[1]: *** [Makefile:197: nuttx] Error 1 + make: *** [tools/Unix.mk:545: nuttx] Error 2 + +Step6 : Implementing +-------------------- + +There are some implementation items, major items are bellow listed. To pass the Linking, try to implement these symboles. + ++-----------------+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ +| Category | Item | Comment | ++-----------------+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ +| SoC directory | entory point : __star | see the PR : https://github.com/apache/nuttx/pull/12441 | ++ +-----------------------+ + +| | Serial Driver | | ++ +-----------------------+ + +| | IDLE task stack | | ++ +-----------------------+ + +| | INTC | | ++ +-----------------------+ + +| | Timer | | ++-----------------+-----------------------+--------------------------------------------------------------------------------------------------------------------+------------------------+ +| Board directory | board_app_initialize | see :doc:`/applications/nsh/customizing` |see :ref:`out-of-tree`. | ++ +-----------------------+--------------------------------------------------------------------------------------------------------------------+ | +| |<arch>_board_initialize| see : BOARD_EARLY_INITIALIZ or BOARD_LATE_INITIALIZE of https://github.com/apache/nuttx/blob/master/sched/Kconfig. | | ++-----------------+-----------------------+--------------------------------------------------------------------------------------------------------------------+------------------------+ + +If got the pass of Linking, you would see follwoing result. + +.. code-block:: + + $ make + Create version.h + LN: platform/board to /home/lassdk/workdir/nuttx2/apps/platform/dummy + Register: nsh + Register: sh + CPP: /home/lassdk/workdir/nuttx2/nuttx/../boards/cb2sdb2/scripts/cb2sdb2.ld-> /home/lassdk/workdir/nuttx2/nuttx/../boarLD: nuttx + +Step7 : Verifying +----------------- + +To execulte and debug on the evalutaion board, add following configurations. + +.. code-block:: + + CONFIG_RAW_BINARY=y + CONFIG_DEBUG_SYMBOLS=y + +If your implementations were good, you would see following logs. + +.. code-block:: + + NuttShell (NSH) NuttX-12.4.0 + nsh> + nsh> + nsh> + +After comfirming to boot NuttShell(NSH), try to execute "apps/testing/ostest". +The "apps/testing/ostest" needs following configurations. + +.. code-block:: + + CONFIG_BUILTIN=y + CONFIG_NSH_BUILTIN_APPS=y + CONFIG_SCHED_WAITPID=y + CONFIG_TESTING_OSTEST=y + +And one more test is recomended to check the timer implementation whether the kernel could count the time accurately or not. Review Comment: Don't think this should be in the scope of this guide. Previously the goal was to have NuttShell show up -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org