diff --git a/README.md b/README.md index 2621394f5b2ea159a9b64f07b8ae8c252041e331..fae9f76cf583a6cc8b271baf618799b247466957 100644 --- a/README.md +++ b/README.md @@ -52,10 +52,10 @@ $ git clone https://gitedu.hesge.ch/soma/scalp_firmware.git $ cd scalp_firmware ``` -Then checkout the **SCALP-SAFE-v0.5** tag. +Then checkout the **SCALP-SAFE-v0.5.1** tag. ``` -$ git checkout SCALP-SAFE-v0.5 +$ git checkout SCALP-SAFE-v0.5.1 ``` ## PetaLinux safe firmware @@ -93,19 +93,21 @@ and File -> Export -> Export Hardware -> include bitstream ### Clone of the GIT Scalp PetaLinux repository +**For information:** [Howto flash QSPI memory quickly](#howto-flash-qspi-memory-quickly) + ``` $ cd <SCALP_PROJECT_FOLDER> $ git clone https://gitedu.hesge.ch/soma/scalp_petalinux.git $ cd scalp_petalinux ``` -Then checkout the **SCALP-SAFE-v0.5** tag. +Then checkout the **SCALP-SAFE-v0.5.1** tag. ``` -$ git checkout SCALP-SAFE-v0.5 +$ git checkout SCALP-SAFE-v0.5.1 ``` -**Use version 0.5 for the GIT scalp_petalinux repository and version 0.5 for the GIT scalp_firmware repository. Be careful, sometimes the versions are identical, but depending on the evolution of the FPGA firmware and the PetaLinux firmware, the versions may be different.** +**Use version 0.5.1 for the GIT scalp_petalinux repository and version 0.5.1 for the GIT scalp_firmware repository. Be careful, sometimes the versions are identical, but depending on the evolution of the FPGA firmware and the PetaLinux firmware, the versions may be different.** ### Create a new Scalp Safe Petalinux project from a BSP @@ -117,7 +119,7 @@ $ petalinux-create --type project -s <path-to-bsp> --name <PROJECT NAME> $ cd <PROJECT NAME> ``` -In my case **\<path-to-bsp\>** corresponds to /home/jo/Documents/Projets/Hepia/scalp_project/scalp_petalinux/bsp/SCALP-SAFE-FIRMWARE-BSP-V0.5.bsp +In my case **\<path-to-bsp\>** corresponds to /home/jo/Documents/Projets/Hepia/scalp_project/scalp_petalinux/bsp/SCALP-SAFE-FIRMWARE-BSP-V0.5.1.bsp ### Importing hardware configuration @@ -297,7 +299,7 @@ The image content can be produced by using the **mkenvimage** command. ``` $ echo -e "custom_board_name=\"Zynq Scalp Board\"\ncustom_board_version=\"RevB 2008\"\ncustom_board_vendor=\"Hepia CoRES - LSN\"" > images/linux/uenv-vol.env -$ /tools/u-boot-tools/mkenvimage -s 0x100000 -o images/linux/uenv-vol.env.bin images/linux/uenv-vol.env +$ ../tools/u-boot-tools/mkenvimage -s 0x100000 -o images/linux/uenv-vol.env.bin images/linux/uenv-vol.env ``` In my case, I copied the tools produced by U-Boot into the **/tools/u-boot-tools/** folder. @@ -352,8 +354,8 @@ echo [INFO] Setup MAC address and IP address; run setup_eth; setenv boot_from_qspi \"ubi part \${UBI_PART_NAME} && ubifsmount \${UBI_PART_ID}:\${UBI_DATAFS_VOL_NAME} && ubifsload \${UBI_VOL_LOAD_ADDR} /\${KERNEL_FIT_IMAGE_NAME} && ubifsumount && ubi detach && iminfo \${UBI_VOL_LOAD_ADDR} && bootm \${UBI_VOL_LOAD_ADDR}\"; setenv boot_from_mmc \"bootm \${loadaddr}\" -setenv bootargs_ubifs \"\${mtdparts} ubi.mtd=1 root=ubi0:rootfs-vol rootfstype=ubifs rw earlyprintk cpuidle.off=1 crashkernel=256M ip=\${ipaddr}:::::eth0\" -setenv bootargs_ext4 \"\${mtdparts} root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait earlyprintk cpuidle.off=1 crashkernel=256M ip=\${ipaddr}:::::eth0\" +setenv bootargs_ubifs \"\${mtdparts} ubi.mtd=1 root=ubi0:rootfs-vol rootfstype=ubifs rw earlyprintk cpuidle.off=1 crashkernel=256M uio_pdrv_genirq.of_id=generic-uio ip=\${ipaddr}:::::eth0\" +setenv bootargs_ext4 \"\${mtdparts} root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait earlyprintk cpuidle.off=1 crashkernel=256M uio_pdrv_genirq.of_id=generic-uio ip=\${ipaddr}:::::eth0\" setenv custom_autoboot \"echo Scalp board autoboot from QSPI && run boot_from_qspi\" setenv bootcmd \"run spi_init && run uenv_scr_load\"; echo [INFO] Check if the file /\${KERNEL_FIT_IMAGE_NAME} exists; @@ -363,20 +365,20 @@ echo [INFO] Check if the file /init exists; if ext4load mmc 0:2 \${initloadaddr} /init ; then echo [INFO] /init found; echo [INFO] Config bootargs for MMC EXT4; -setenv bootargs \"\${mtdparts} root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait earlyprintk cpuidle.off=1 crashkernel=256M ip=\${ipaddr}:::::eth0\"; +setenv bootargs \"\${mtdparts} root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait earlyprintk cpuidle.off=1 crashkernel=256M uio_pdrv_genirq.of_id=generic-uio ip=\${ipaddr}:::::eth0\"; echo [INFO] Config boot mode from MMC; setenv custom_autoboot \"echo Scalp board autoboot from MMC && run boot_from_mmc\"; else echo [INFO] init not found; echo [INFO] Config bootargs for UBI/UBIFS; -setenv bootargs \"\${mtdparts} ubi.mtd=1 root=ubi0:rootfs-vol rootfstype=ubifs rw earlyprintk cpuidle.off=1 crashkernel=256M ip=\${ipaddr}:::::eth0\"; +setenv bootargs \"\${mtdparts} ubi.mtd=1 root=ubi0:rootfs-vol rootfstype=ubifs rw earlyprintk cpuidle.off=1 crashkernel=256M uio_pdrv_genirq.of_id=generic-uio ip=\${ipaddr}:::::eth0\"; echo [INFO] Config boot mode from SPI NOR; setenv custom_autoboot \"echo Scalp board autoboot from QSPI && run boot_from_qspi\"; fi else echo [INFO] /\${KERNEL_FIT_IMAGE_NAME} not found; echo [INFO] Config bootargs for UBI/UBIFS; -setenv bootargs \"\${mtdparts} ubi.mtd=1 root=ubi0:rootfs-vol rootfstype=ubifs rw earlyprintk cpuidle.off=1 crashkernel=256M ip=\${ipaddr}:::::eth0\"; +setenv bootargs \"\${mtdparts} ubi.mtd=1 root=ubi0:rootfs-vol rootfstype=ubifs rw earlyprintk cpuidle.off=1 crashkernel=256M uio_pdrv_genirq.of_id=generic-uio ip=\${ipaddr}:::::eth0\"; echo [INFO] Config boot mode from SPI NOR; setenv custom_autoboot \"echo Scalp board autoboot from QSPI && run boot_from_qspi\"; fi @@ -384,7 +386,7 @@ run custom_autoboot" > uenv.scr.txt ``` ``` -$ /tools/u-boot-tools/mkimage -T script -C none -n 'Scalp U-Boot Script File' -A arm -d uenv.scr.txt uenv.scr +$ ../../../tools/u-boot-tools/mkimage -T script -C none -n 'Scalp U-Boot Script File' -A arm -d uenv.scr.txt uenv.scr ``` Copy U-Boot script into datafs-vol @@ -705,10 +707,10 @@ The **image.ub** file corresponds to the image of the Linux kernel, the device t The image content can be viewed using the **dumpimage** command. ``` -$ /tools/u-boot-tools/dumpimage -l image.ub +$ ../tools/u-boot-tools/dumpimage -l image.ub ``` -In my case, I copied the tools produced by U-Boot into the **/tools/u-boot-tools/** folder. +In my case, I copied the tools produced by U-Boot into the **../tools/u-boot-tools/** folder. **This is the end of the long way to your safe firmware.** @@ -724,10 +726,10 @@ The user firmware must be installed on an MMC card with an EXT4 file system. The #### Checkout the current tag -Then checkout the **SCALP-SAFE-v0.5** tag. +Then checkout the **SCALP-USER-v0.5.1** tag. ``` -$ git checkout SCALP-USER-v0.5 +$ git checkout SCALP-USER-v0.5.1 ``` **If you have not gone through the scalp\_safe\_petalinux firmware creation section, please go to section [Copy Scalp board files](#copy-scalp-board-files).** @@ -759,13 +761,13 @@ $ git clone https://gitedu.hesge.ch/soma/scalp_petalinux.git $ cd scalp_petalinux ``` -Then checkout the **SCALP-USER-v0.5** tag. +Then checkout the **SCALP-USER-v0.5.1** tag. ``` -$ git checkout SCALP-USER-v0.5 +$ git checkout SCALP-USER-v0.5.1 ``` -**Use version 0.5 for the GIT scalp_petalinux repository and version 0.5 for the GIT scalp_firmware repository. Be careful, sometimes the versions are identical, but depending on the evolution of the FPGA firmware and the PetaLinux firmware, the versions may be different.** +**Use version 0.5.1 for the GIT scalp_petalinux repository and version 0.5.1 for the GIT scalp_firmware repository. Be careful, sometimes the versions are identical, but depending on the evolution of the FPGA firmware and the PetaLinux firmware, the versions may be different.** ### Create a new Scalp User Petalinux project from a BSP @@ -777,7 +779,7 @@ $ petalinux-create --type project -s <path-to-bsp> --name <PROJECT NAME> $ cd <PROJECT NAME> ``` -In my case **\<path-to-bsp\>** corresponds to /home/jo/Documents/Projets/Hepia/scalp_project/scalp_petalinux/bsp/SCALP-USER-FIRMWARE-BSP-V0.5.bsp +In my case **\<path-to-bsp\>** corresponds to /home/jo/Documents/Projets/Hepia/scalp_project/scalp_petalinux/bsp/SCALP-USER-FIRMWARE-BSP-V0.5.1.bsp ### Importing hardware configuration @@ -869,7 +871,31 @@ $ sudo dd if=./images/linux/virtualfs-ext4.img of=/dev/\<MMC_DEV_NODE\> status=p **This section contains HOWTO documentation. It is not necessary to follow them to produce firmware.** -### Howto access UBIFS partitions from U-Boot. +### Howto flash QSPI memory quickly + +Go to the PetaLinux folder... + +``` +$ cd <SCALP_PROJECT_FOLDER>/scalp_petalinux/ +``` + +If you are using a single JTAG probe. + +**With a check of the written blocks...** + +``` +$ program_flash -blank_check -verify -frequency 30000000 -f firmware-bin/BOOT.BIN -offset 0 -flash_type qspi-x4-single -fsbl firmware-bin/zynq_fsbl.elf -cable type xilinx_tcf url TCP:127.0.0.1:3121 +``` + +**Or, without a check of the written blocks...** + +``` +$ program_flash -frequency 30000000 -f firmware-bin/BOOT.BIN -offset 0 -flash_type qspi-x4-single -fsbl firmware-bin/zynq_fsbl.elf -cable type xilinx_tcf url TCP:127.0.0.1:3121 +``` + +The **program_flash** command is located in the Vitis installation folder **/\<VITIS_PATH\>/2020.2/bin/program_flash** or in the PetaLinux installation folder **/\<PETALINUX_PATH\>/2020.2/bin/tools/xsct/bin**. + +### Howto access UBIFS partitions from U-Boot The SPI NOR memory is activated. @@ -1402,6 +1428,95 @@ $ petalinux-build **If you prefer to start by cleaning up your project, don't forget to add the ZYNQ_SPI driver and the CMD_UBI and CMD_UBIFS commands again in the U-Boot configuration. And yes, the bug is still there.** +### Howto create a custom C application + +``` +$ petalinux-create -t apps --template c --name rgbleds-ctrl --enable +``` + +``` +$ cd project-spec/meta-user/recipes-apps/rgbleds-ctrl/files +``` + +Edit **rgbleds-ctrl.c** + +``` +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> +#include <ctype.h> + +#define MAP_SIZE 0x1000 +#define SET_REG_IDX 0x1 +#define CLR_REG_IDX 0x2 +#define RED_VALUE 0x1 +#define GREEN_VALUE 0x2 +#define BLUE_VALUE 0x4 + +int main(int argc, char **argv) +{ + int c; + int uiofd; + volatile unsigned *uioptr = NULL; + + + if(argc > 1) + { + fprintf (stderr, "Unknown option"); + return EXIT_FAILURE; + } + + uiofd = open("/dev/uio0", O_RDWR); + if(uiofd < 0) + { + perror("uio open:"); + return errno; + } + + uioptr = (volatile unsigned *)mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, uiofd, 0); + + if(uioptr == MAP_FAILED) + { + perror("uio mmap:"); + return errno; + } + + uioptr[SET_REG_IDX] = GREEN_VALUE; + + munmap((void*)uioptr, MAP_SIZE); + close(uiofd); + + return 0; +} +``` + +Go to root PetaLinux folder. + +``` +cd ../../../../ +``` + +Then we build the package and integrate it into the file system. + +``` +$ petalinux-build -c rgbleds-ctrl -x do_cleanall +$ petalinux-build -c rgbleds-ctrl +$ petalinux-build -c rgbleds-ctrl -x do_install -f +``` + +``` +$ petalinux-build -c rootfs +$ petalinux-build +``` + +Finally we rebuild the firmware. + ### Howto create a new BSP TODO @@ -1411,3 +1526,23 @@ $ petalinux-package --bsp -p /home/jo/Documents/Projets/Hepia/scalp_project/scal $ petalinux-package --bsp -p /home/jo/Documents/Projets/Hepia/scalp_project/scalp_petalinux/scalp_user_petalinux --hwsource=/home/jo/Documents/Projets/Hepia/scalp_project/scalp_firmware/designs/vivado/scalp_firmware/2020.2/lin64/scalp_firmware --output SCALP-USER-FIRMWARE-BSP-V0.N --force ``` + +### Some useful code snippets... + +``` +/ { + amba_pl: amba_pl { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges ; + + scalp_safe_firmware_0: scalp_safe_firmware_reg_bank@43c10000 { + //clock-names = "SAxiClkxCI"; + //clocks = <&clkc 15>; + compatible = "generic-uio"; + reg = <0x43c10000 0x1000>; + }; + }; +}; +``` diff --git a/bsp/SCALP-SAFE-FIRMWARE-BSP-V0.5.1.bsp b/bsp/SCALP-SAFE-FIRMWARE-BSP-V0.5.1.bsp new file mode 100644 index 0000000000000000000000000000000000000000..f95b1d447be5e1bef08021287be9d16fad53d540 Binary files /dev/null and b/bsp/SCALP-SAFE-FIRMWARE-BSP-V0.5.1.bsp differ diff --git a/bsp/SCALP-USER-FIRMWARE-BSP-V0.5.1.bsp b/bsp/SCALP-USER-FIRMWARE-BSP-V0.5.1.bsp new file mode 100644 index 0000000000000000000000000000000000000000..c5edf5475aa1084655c3fdc72802d04f4238dde3 Binary files /dev/null and b/bsp/SCALP-USER-FIRMWARE-BSP-V0.5.1.bsp differ diff --git a/scalp_safe_petalinux/.petalinux/metadata b/scalp_safe_petalinux/.petalinux/metadata index a156097bfb49072597eb217932587c0bd9539389..53b585dd02b086cbc031c6b76e03422b7fac7f4c 100644 --- a/scalp_safe_petalinux/.petalinux/metadata +++ b/scalp_safe_petalinux/.petalinux/metadata @@ -1,6 +1,6 @@ PETALINUX_VER=2020.2 VALIDATE_HW_CHKSUM=1 HARDWARE_PATH=/home/jo/Documents/Projets/Hepia/scalp_project/scalp_firmware/designs/vivado/scalp_safe_firmware/2020.2/lin64/scalp_safe_firmware/scalp_safe_firmware.xsa -HARDWARE_CHECKSUM=22057c831a5da395a402d5607574725d +HARDWARE_CHECKSUM=91eb3d89159742ce85fd8ae3c9dd6873 YOCTO_SDK=5ff8fc5f85d1566b314bb73eaa378212 -RFSCONFIG_CHKSUM=cbbefadac8312a93a2731682ecb50ade +RFSCONFIG_CHKSUM=9e2ee1d8279802991e61c5f6eb9d9e2d diff --git a/scalp_safe_petalinux/project-spec/configs/config b/scalp_safe_petalinux/project-spec/configs/config index 7c2c70627239b6251eb61e12c3d98997760e9806..601c6ea1cdba5328ac14eb4bc2ef061a947ba49f 100644 --- a/scalp_safe_petalinux/project-spec/configs/config +++ b/scalp_safe_petalinux/project-spec/configs/config @@ -176,7 +176,7 @@ CONFIG_SUBSYSTEM_EXTRA_DT_FILES="" # CONFIG_SUBSYSTEM_BOOTARGS_AUTO=y CONFIG_SUBSYSTEM_BOOTARGS_EARLYPRINTK=y - +CONFIG_SUBSYSTEM_BOOTARGS_GENERATED="console=ttyPS0,115200 earlycon" CONFIG_SUBSYSTEM_DEVICETREE_COMPILER_FLAGS="-@" # CONFIG_SUBSYSTEM_DTB_OVERLAY is not set # CONFIG_SUBSYSTEM_REMOVE_PL_DTB is not set @@ -270,4 +270,3 @@ CONFIG_YOCTO_NETWORK_SSTATE_FEEDS_URL="http://petalinux.xilinx.com/sswreleases/r # User Layers # CONFIG_USER_LAYER_0="" -CONFIG_SUBSYSTEM_BOOTARGS_GENERATED="console=ttyPS0,115200 earlycon" diff --git a/scalp_safe_petalinux/project-spec/configs/rootfs_config b/scalp_safe_petalinux/project-spec/configs/rootfs_config index 26dbf1e876fe91e40ae49212caedcc5a8ae431fd..3fc6879566b4f1a135d202b89209cd69a2df0e0e 100644 --- a/scalp_safe_petalinux/project-spec/configs/rootfs_config +++ b/scalp_safe_petalinux/project-spec/configs/rootfs_config @@ -4026,12 +4026,14 @@ CONFIG_bitstream-conf=y CONFIG_bitstream-init=y # CONFIG_gpio-demo is not set # CONFIG_peekpoke is not set +CONFIG_rgbleds-ctrl=y CONFIG_sja1105-conf=y CONFIG_sja1105-init=y # # user packages # +# CONFIG_rgbleds-ctrl-init is not set # # PetaLinux RootFS Settings diff --git a/scalp_safe_petalinux/project-spec/hw-description/scalp_safe_firmware.bit b/scalp_safe_petalinux/project-spec/hw-description/scalp_safe_firmware.bit index 738ba71a3a5e32e05d359c4541c80dd7737559f0..c9719bcab30283841d8f258267a40f9de6c9446d 100644 Binary files a/scalp_safe_petalinux/project-spec/hw-description/scalp_safe_firmware.bit and b/scalp_safe_petalinux/project-spec/hw-description/scalp_safe_firmware.bit differ diff --git a/scalp_safe_petalinux/project-spec/hw-description/system.xsa b/scalp_safe_petalinux/project-spec/hw-description/system.xsa index 561d925b9ad188674f9925dc1f8e63da23e7dd54..b7ccf03ce6dfba140bf1353b588edd7d39c67b9a 100644 Binary files a/scalp_safe_petalinux/project-spec/hw-description/system.xsa and b/scalp_safe_petalinux/project-spec/hw-description/system.xsa differ diff --git a/scalp_safe_petalinux/project-spec/meta-user/conf/user-rootfsconfig b/scalp_safe_petalinux/project-spec/meta-user/conf/user-rootfsconfig index a31c7cda48ce9c38e14fe43553117c0ce9590b37..4f50fca776bf14c6cbc71aa6f9254d463043eaae 100644 --- a/scalp_safe_petalinux/project-spec/meta-user/conf/user-rootfsconfig +++ b/scalp_safe_petalinux/project-spec/meta-user/conf/user-rootfsconfig @@ -7,3 +7,5 @@ CONFIG_sja1105-init CONFIG_sja1105-conf CONFIG_bitstream-init CONFIG_bitstream-conf +CONFIG_rgbleds-ctrl +CONFIG_rgbleds-ctrl-init diff --git a/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/.gdbinit b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/.gdbinit new file mode 100644 index 0000000000000000000000000000000000000000..d59fb8d90efb393c83d35becbecddcfa493a5e67 --- /dev/null +++ b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/.gdbinit @@ -0,0 +1,2 @@ +# Load the PetaLinux SDK main gdbinit script +source plnx_gdbinit diff --git a/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/README b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/README new file mode 100644 index 0000000000000000000000000000000000000000..2bfe1817319735283df7a978589c0d2ef488fa51 --- /dev/null +++ b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/README @@ -0,0 +1,32 @@ +PetaLinux User Application Template +=================================== + +This directory contains a PetaLinux user application created from a template. + +If you are developing your application from scratch, simply start editing the +file rgbleds-ctrl.c. + +You can easily import any existing application code by copying it into this +directory, and editing the automatically generated Makefile. + +Before building the application, you will need to enable the application +from PetaLinux menuconfig by running: + "petalinux-config -c rootfs" +You will see your application in the "apps --->" submenu. + +To build your application, simply run "petalinux-build -c rgbleds-ctrl". +This command will build your application and will install your application +into the target file system host copy. + +You will also need to rebuild PetaLinux bootable images so that the images +is updated with the updated target filesystem copy, run this command: + "petalinux-build -c rootfs" + +You can also run one PetaLinux command to install the application to the +target filesystem host copy and update the bootable images as follows: + "petalinux-build" + +To add extra source code files (for example, to split a large application into +multiple source files), add the relevant .o files to the list in the local +Makefile where indicated. + diff --git a/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/files/Makefile b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/files/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..b81f25152804fa23bca542110ed48fd1e9dcc6cf --- /dev/null +++ b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/files/Makefile @@ -0,0 +1,14 @@ +APP = rgbleds-ctrl + +# Add any other object files to this list below +APP_OBJS = rgbleds-ctrl.o + +all: build + +build: $(APP) + +$(APP): $(APP_OBJS) + $(CC) -o $@ $(APP_OBJS) $(LDFLAGS) $(LDLIBS) +clean: + rm -f $(APP) *.o + diff --git a/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/files/rgbleds-ctrl.c b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/files/rgbleds-ctrl.c new file mode 100644 index 0000000000000000000000000000000000000000..2092b7aa87e66422f1f6eefc5dc4a064dfd4413c --- /dev/null +++ b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/files/rgbleds-ctrl.c @@ -0,0 +1,80 @@ +/* +* Copyright (C) 2013 - 2016 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person +* obtaining a copy of this software and associated documentation +* files (the "Software"), to deal in the Software without restriction, +* including without limitation the rights to use, copy, modify, merge, +* publish, distribute, sublicense, and/or sell copies of the Software, +* and to permit persons to whom the Software is furnished to do so, +* subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in this +* Software without prior written authorization from Xilinx. +* +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> +#include <ctype.h> + +#define MAP_SIZE 0x1000 +#define SET_REG_IDX 0x1 +#define CLR_REG_IDX 0x2 +#define RED_VALUE 0x1 +#define GREEN_VALUE 0x2 +#define BLUE_VALUE 0x4 + +int main(int argc, char **argv) +{ + int c; + int uiofd; + volatile unsigned *uioptr = NULL; + + + if(argc > 1) + { + fprintf (stderr, "Unknown option"); + return EXIT_FAILURE; + } + + uiofd = open("/dev/uio0", O_RDWR); + if(uiofd < 0) + { + perror("uio open:"); + return errno; + } + + uioptr = (volatile unsigned *)mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, uiofd, 0); + + if(uioptr == MAP_FAILED) + { + perror("uio mmap:"); + return errno; + } + + uioptr[SET_REG_IDX] = GREEN_VALUE; + + munmap((void*)uioptr, MAP_SIZE); + close(uiofd); + + return 0; +} diff --git a/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/files/rgbleds-ctrl.c~ b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/files/rgbleds-ctrl.c~ new file mode 100644 index 0000000000000000000000000000000000000000..fbc001668a2f0b6de1abc33ab41976831bc5388e --- /dev/null +++ b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/files/rgbleds-ctrl.c~ @@ -0,0 +1,137 @@ +/* +* Copyright (C) 2013 - 2016 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person +* obtaining a copy of this software and associated documentation +* files (the "Software"), to deal in the Software without restriction, +* including without limitation the rights to use, copy, modify, merge, +* publish, distribute, sublicense, and/or sell copies of the Software, +* and to permit persons to whom the Software is furnished to do so, +* subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in this +* Software without prior written authorization from Xilinx. +* +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> +#include <ctype.h> + +#define MAP_SIZE 0x1000 +#define SET_REG_IDX 0x1 +#define CLR_REG_IDX 0x2 +#define RED_VALUE 0x1 +#define GREEN_VALUE 0x2 +#define BLUE_VALUE 0x4 + +int main(int argc, char **argv) +{ + int c; + int uiofd; + volatile unsigned *uioptr = NULL; + int status = 0; + char *rvalue = NULL; + char *gvalue = NULL; + char *bvalue = NULL; + char *setstr = "1"; + + if(argc < 2) + { + fprintf (stderr, "Unknown option `-%c'.\n", optopt); + fprintf (stderr, "Usage\n\t%s -r 1|0 -g 1|0 -b 1|0 \n", argv[0]); + return EXIT_FAILURE; + } + + while((c = getopt(argc, argv, "r:g:b:")) != -1) { + switch(c) { + case 'r': + rvalue = optarg; + break; + case 'g': + gvalue = optarg; + break; + case 'b': + bvalue = optarg; + break; + case '?': + + if((optopt == 'r') || (optopt == 'g') || (optopt == 'b')) + fprintf (stderr, "Option -%c requires an argument.\n", optopt); + else if(isprint(optopt)) + fprintf (stderr, "Unknown option `-%c'.\n", optopt); + else + fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt); + + fprintf (stderr, "Usage\n\t%s -r 1|0 -g 1|0 -b 1|0 \n", argv[0]); + return EXIT_FAILURE; + + default: + fprintf (stderr, "Unknown option `-%c'.\n", optopt); + fprintf (stderr, "Usage\n\t%s -r 1|0 -g 1|0 -b 1|0 \n", argv[0]); + return EXIT_FAILURE; + } + } + + uiofd = open("/dev/uio0", O_RDWR); + if(uiofd < 0) + { + perror("uio open:"); + return errno; + } + + uioptr = (volatile unsigned *)mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, uiofd, 0); + + if(uioptr == MAP_FAILED) + { + perror("uio mmap:"); + return errno; + } + + if(rvalue != NULL) + { + if(strncmp(rvalue, setstr, 1)) + uioptr[SET_REG_IDX] = RED_VALUE; + else + uioptr[CLR_REG_IDX] = RED_VALUE; + } + + if(gvalue != NULL) + { + if(strncmp(gvalue, setstr, 1)) + uioptr[SET_REG_IDX] = GREEN_VALUE; + else + uioptr[CLR_REG_IDX] = GREEN_VALUE; + } + + if(bvalue != NULL) + { + if(strncmp(gvalue, setstr, 1)) + uioptr[SET_REG_IDX] = BLUE_VALUE; + else + uioptr[CLR_REG_IDX] = BLUE_VALUE; + } + + munmap((void*)uioptr, MAP_SIZE); + close(uiofd); + + return 0; +} diff --git a/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/rgbleds-ctrl.bb b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/rgbleds-ctrl.bb new file mode 100644 index 0000000000000000000000000000000000000000..33b4b96e012ba9b4c8f4b215558686a92fed8a32 --- /dev/null +++ b/scalp_safe_petalinux/project-spec/meta-user/recipes-apps/rgbleds-ctrl/rgbleds-ctrl.bb @@ -0,0 +1,23 @@ +# +# This file is the rgbleds-ctrl recipe. +# + +SUMMARY = "Simple rgbleds-ctrl application" +SECTION = "PETALINUX/apps" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +SRC_URI = "file://rgbleds-ctrl.c \ + file://Makefile \ + " + +S = "${WORKDIR}" + +do_compile() { + oe_runmake +} + +do_install() { + install -d ${D}${bindir} + install -m 0755 rgbleds-ctrl ${D}${bindir} +} diff --git a/scalp_safe_petalinux/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi b/scalp_safe_petalinux/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi index 2c0e8cc6497ed7de071acfe01eecb0ea4c4bf7a0..0f7bfad1db28a80c346cc7595b5d0102101d433f 100644 --- a/scalp_safe_petalinux/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi +++ b/scalp_safe_petalinux/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi @@ -35,16 +35,32 @@ }; chosen { - bootargs = "earlyprintk cpuidle.off=1 crashkernel=256M rw"; + bootargs = "earlyprintk cpuidle.off=1 crashkernel=256M rw uio_pdrv_genirq.of_id=generic-uio"; stdout-path = "serial0:115200n8"; xlnx,eeprom = &eeprom; }; }; +/ { + amba_pl: amba_pl { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges ; + + scalp_safe_firmware_0: scalp_safe_firmware_reg_bank@43c10000 { + //clock-names = "SAxiClkxCI"; + //clocks = <&clkc 15>; + compatible = "generic-uio"; + reg = <0x43c10000 0x1000>; + }; + }; +}; + /* PS_Clk50M_i */ &clkc { - fclk-enable = <0x1>; - ps-clk-frequency = <50000000>; + fclk-enable = <0x1>; + ps-clk-frequency = <50000000>; }; &intc { diff --git a/scalp_safe_petalinux/project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h b/scalp_safe_petalinux/project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h index aad0ddbe1a6673144264bab2603cfe6cdcd663a5..5172454462ab36f60c61dbe5c144ba761f83d90e 100644 --- a/scalp_safe_petalinux/project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h +++ b/scalp_safe_petalinux/project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h @@ -62,5 +62,5 @@ //#define CONFIG_ETHADDR "02:00:00:c5:64:64" #define MTDIDS_DEFAULT "nor0=nor_flash" #define MTDPARTS_DEFAULT "mtdparts=nor_flash:5m(boot)ro,-(ubi)" -#define CONFIG_BOOTARGS "${mtdparts} ubi.mtd=1 root=ubi0:rootfs-vol rootfstype=ubifs rw earlyprintk cpuidle.off=1 crashkernel=256M ip=${ipaddr}:::::eth0" +#define CONFIG_BOOTARGS "${mtdparts} ubi.mtd=1 root=ubi0:rootfs-vol rootfstype=ubifs rw earlyprintk cpuidle.off=1 crashkernel=256M uio_pdrv_genirq.of_id=generic-uio ip=${ipaddr}:::::eth0" #define CONFIG_BOOTCOMMAND "run custom_autoboot" diff --git a/scalp_safe_petalinux/project-spec/meta-user/recipes-kernel/linux/linux-xlnx/devtool-fragment.cfg b/scalp_safe_petalinux/project-spec/meta-user/recipes-kernel/linux/linux-xlnx/devtool-fragment.cfg index f8de3f1786eb80970495eb717aa352f31d339a53..273cc45cfab40930670e63e3fc759a88ba786109 100644 --- a/scalp_safe_petalinux/project-spec/meta-user/recipes-kernel/linux/linux-xlnx/devtool-fragment.cfg +++ b/scalp_safe_petalinux/project-spec/meta-user/recipes-kernel/linux/linux-xlnx/devtool-fragment.cfg @@ -134,3 +134,7 @@ CONFIG_ZSTD_DECOMPRESS=y CONFIG_ASSOCIATIVE_ARRAY=y CONFIG_SGL_ALLOC=y CONFIG_OID_REGISTRY=y +CONFIG_UIO=y +CONFIG_UIO_PDRV_GENIRQ=y +CONFIG_UIO_PCI_GENERIC=y +CONFIG_UIO_PDRV_GENIRQ=y