diff options
| author | John Toomey <john.toomey@amd.com> | 2024-07-22 11:33:49 +0100 |
|---|---|---|
| committer | Mark Hatle <mark.hatle@amd.com> | 2024-07-23 10:09:06 -0600 |
| commit | 940dcc02509d32735bf59a78030822a8d32a46fb (patch) | |
| tree | e4f2442850d22582a8f732e0f1d856a7c5ad5b97 /meta-xilinx-demos/recipes-examples | |
| parent | eccec2511d14d53e4cede82953e97af1de31091a (diff) | |
| download | meta-xilinx-940dcc02509d32735bf59a78030822a8d32a46fb.tar.gz | |
Move example code to meta-xilinx-demos
Signed-off-by: John Toomey <john.toomey@amd.com>
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Diffstat (limited to 'meta-xilinx-demos/recipes-examples')
12 files changed, 1189 insertions, 0 deletions
diff --git a/meta-xilinx-demos/recipes-examples/gpio-demo/files/Makefile b/meta-xilinx-demos/recipes-examples/gpio-demo/files/Makefile new file mode 100644 index 00000000..9106be1b --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/gpio-demo/files/Makefile | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | APP = gpio-demo | ||
| 2 | |||
| 3 | # Add any other object files to this list below | ||
| 4 | APP_OBJS = gpio-demo.o | ||
| 5 | |||
| 6 | all: $(APP) | ||
| 7 | |||
| 8 | $(APP): $(APP_OBJS) | ||
| 9 | $(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS) | ||
| 10 | |||
| 11 | clean: | ||
| 12 | -rm -f $(APP) *.elf *.gdb *.o | ||
| 13 | |||
| 14 | |||
diff --git a/meta-xilinx-demos/recipes-examples/gpio-demo/files/gpio-demo.c b/meta-xilinx-demos/recipes-examples/gpio-demo/files/gpio-demo.c new file mode 100644 index 00000000..4e17779d --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/gpio-demo/files/gpio-demo.c | |||
| @@ -0,0 +1,355 @@ | |||
| 1 | /* | ||
| 2 | * | ||
| 3 | * gpio-demo app | ||
| 4 | * | ||
| 5 | * Copyright (C) 2013 - 2016 Xilinx, Inc. All rights reserved. | ||
| 6 | * | ||
| 7 | * Permission is hereby granted, free of charge, to any person | ||
| 8 | * obtaining a copy of this software and associated documentation | ||
| 9 | * files (the "Software"), to deal in the Software without restriction, | ||
| 10 | * including without limitation the rights to use, copy, modify, merge, | ||
| 11 | * publish, distribute, sublicense, and/or sell copies of the Software, | ||
| 12 | * and to permit persons to whom the Software is furnished to do so, | ||
| 13 | * subject to the following conditions: | ||
| 14 | * | ||
| 15 | * The above copyright notice and this permission notice shall be included | ||
| 16 | * in all copies or substantial portions of the Software. | ||
| 17 | * | ||
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| 21 | * IN NO EVENT SHALL XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
| 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 24 | * | ||
| 25 | * Except as contained in this notice, the name of the Xilinx shall not be used | ||
| 26 | * in advertising or otherwise to promote the sale, use or other dealings in this | ||
| 27 | * Software without prior written authorization from Xilinx. | ||
| 28 | * | ||
| 29 | */ | ||
| 30 | |||
| 31 | #include <stdio.h> | ||
| 32 | #include <stdlib.h> | ||
| 33 | #include <unistd.h> | ||
| 34 | #include <string.h> | ||
| 35 | #include <errno.h> | ||
| 36 | #include <fcntl.h> | ||
| 37 | #include <signal.h> | ||
| 38 | |||
| 39 | #define GPIO_ROOT "/sys/class/gpio" | ||
| 40 | #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) | ||
| 41 | |||
| 42 | static enum {NONE, IN, OUT, CYLON, KIT} gpio_opt = NONE; | ||
| 43 | |||
| 44 | static const unsigned long cylon[] = { | ||
| 45 | 0x00000080, 0x00000040, 0x00000020, 0x00000010, | ||
| 46 | 0x00000008, 0x00000004, 0x00000002, 0x00000001, | ||
| 47 | 0x00000002, 0x00000004, 0x00000008, | ||
| 48 | 0x00000010, 0x00000020, 0x00000040, 0x00000080, | ||
| 49 | }; | ||
| 50 | |||
| 51 | static const unsigned long kit[] = { | ||
| 52 | 0x000000e0, 0x00000070, 0x00000038, 0x0000001c, | ||
| 53 | 0x0000000e, 0x00000007, 0x00000003, 0x00000001, | ||
| 54 | 0x00000003, 0x00000007, 0x0000000e, | ||
| 55 | 0x0000001c, 0x00000038, 0x00000070, 0x000000e0, | ||
| 56 | }; | ||
| 57 | |||
| 58 | static int gl_gpio_base = 0; | ||
| 59 | |||
| 60 | static void usage (char *argv0) | ||
| 61 | { | ||
| 62 | char *basename = strrchr(argv0, '/'); | ||
| 63 | if (!basename) | ||
| 64 | basename = argv0; | ||
| 65 | |||
| 66 | fprintf(stderr, | ||
| 67 | "Usage: %s [-g GPIO_BASE] COMMAND\n" | ||
| 68 | "\twhere COMMAND is one of:\n" | ||
| 69 | "\t\t-i\t\tInput value from GPIO and print it\n" | ||
| 70 | "\t\t-o\tVALUE\tOutput value to GPIO\n" | ||
| 71 | "\t\t-c\t\tCylon test pattern\n" | ||
| 72 | "\t\t-k\t\t KIT test pattern\n" | ||
| 73 | "\tGPIO_BASE indicates which GPIO chip to talk to (The number can be \n" | ||
| 74 | "\tfound at /sys/class/gpio/gpiochipN).\n" | ||
| 75 | "\tThe highest gpiochipN is the first gpio listed in the dts file, \n" | ||
| 76 | "\tand the lowest gpiochipN is the last gpio listed in the dts file.\n" | ||
| 77 | "\tE.g.If the gpiochip240 is the LED_8bit gpio, and I want to output '1' \n" | ||
| 78 | "\tto the LED_8bit gpio, the command should be:\n" | ||
| 79 | "\t\tgpio-demo -g 240 -o 1\n" | ||
| 80 | "\n" | ||
| 81 | "\tgpio-demo written by Xilinx Inc.\n" | ||
| 82 | "\n" | ||
| 83 | , basename); | ||
| 84 | exit(-2); | ||
| 85 | } | ||
| 86 | |||
| 87 | static int open_gpio_channel(int gpio_base) | ||
| 88 | { | ||
| 89 | char gpio_nchan_file[128]; | ||
| 90 | int gpio_nchan_fd; | ||
| 91 | int gpio_max; | ||
| 92 | int nchannel; | ||
| 93 | char nchannel_str[5]; | ||
| 94 | char *cptr; | ||
| 95 | int c; | ||
| 96 | char channel_str[5]; | ||
| 97 | |||
| 98 | char *gpio_export_file = "/sys/class/gpio/export"; | ||
| 99 | int export_fd=0; | ||
| 100 | |||
| 101 | /* Check how many channels the GPIO chip has */ | ||
| 102 | sprintf(gpio_nchan_file, "%s/gpiochip%d/ngpio", GPIO_ROOT, gpio_base); | ||
| 103 | gpio_nchan_fd = open(gpio_nchan_file, O_RDONLY); | ||
| 104 | if (gpio_nchan_fd < 0) { | ||
| 105 | fprintf(stderr, "Failed to open %s: %s\n", gpio_nchan_file, strerror(errno)); | ||
| 106 | return -1; | ||
| 107 | } | ||
| 108 | read(gpio_nchan_fd, nchannel_str, sizeof(nchannel_str)); | ||
| 109 | close(gpio_nchan_fd); | ||
| 110 | nchannel=(int)strtoul(nchannel_str, &cptr, 0); | ||
| 111 | if (cptr == nchannel_str) { | ||
| 112 | fprintf(stderr, "Failed to change %s into GPIO channel number\n", nchannel_str); | ||
| 113 | exit(1); | ||
| 114 | } | ||
| 115 | |||
| 116 | /* Open files for each GPIO channel */ | ||
| 117 | export_fd=open(gpio_export_file, O_WRONLY); | ||
| 118 | if (export_fd < 0) { | ||
| 119 | fprintf(stderr, "Cannot open GPIO to export %d\n", gpio_base); | ||
| 120 | return -1; | ||
| 121 | } | ||
| 122 | |||
| 123 | gpio_max = gpio_base + nchannel; | ||
| 124 | for(c = gpio_base; c < gpio_max; c++) { | ||
| 125 | sprintf(channel_str, "%d", c); | ||
| 126 | write(export_fd, channel_str, (strlen(channel_str)+1)); | ||
| 127 | } | ||
| 128 | close(export_fd); | ||
| 129 | return nchannel; | ||
| 130 | } | ||
| 131 | |||
| 132 | static int close_gpio_channel(int gpio_base) | ||
| 133 | { | ||
| 134 | char gpio_nchan_file[128]; | ||
| 135 | int gpio_nchan_fd; | ||
| 136 | int gpio_max; | ||
| 137 | int nchannel; | ||
| 138 | char nchannel_str[5]; | ||
| 139 | char *cptr; | ||
| 140 | int c; | ||
| 141 | char channel_str[5]; | ||
| 142 | |||
| 143 | char *gpio_unexport_file = "/sys/class/gpio/unexport"; | ||
| 144 | int unexport_fd=0; | ||
| 145 | |||
| 146 | /* Check how many channels the GPIO chip has */ | ||
| 147 | sprintf(gpio_nchan_file, "%s/gpiochip%d/ngpio", GPIO_ROOT, gpio_base); | ||
| 148 | gpio_nchan_fd = open(gpio_nchan_file, O_RDONLY); | ||
| 149 | if (gpio_nchan_fd < 0) { | ||
| 150 | fprintf(stderr, "Failed to open %s: %s\n", gpio_nchan_file, strerror(errno)); | ||
| 151 | return -1; | ||
| 152 | } | ||
| 153 | read(gpio_nchan_fd, nchannel_str, sizeof(nchannel_str)); | ||
| 154 | close(gpio_nchan_fd); | ||
| 155 | nchannel=(int)strtoul(nchannel_str, &cptr, 0); | ||
| 156 | if (cptr == nchannel_str) { | ||
| 157 | fprintf(stderr, "Failed to change %s into GPIO channel number\n", nchannel_str); | ||
| 158 | exit(1); | ||
| 159 | } | ||
| 160 | |||
| 161 | /* Close opened files for each GPIO channel */ | ||
| 162 | unexport_fd=open(gpio_unexport_file, O_WRONLY); | ||
| 163 | if (unexport_fd < 0) { | ||
| 164 | fprintf(stderr, "Cannot close GPIO by writing unexport %d\n", gpio_base); | ||
| 165 | return -1; | ||
| 166 | } | ||
| 167 | |||
| 168 | gpio_max = gpio_base + nchannel; | ||
| 169 | for(c = gpio_base; c < gpio_max; c++) { | ||
| 170 | sprintf(channel_str, "%d", c); | ||
| 171 | write(unexport_fd, channel_str, (strlen(channel_str)+1)); | ||
| 172 | } | ||
| 173 | close(unexport_fd); | ||
| 174 | return 0; | ||
| 175 | } | ||
| 176 | |||
| 177 | static int set_gpio_direction(int gpio_base, int nchannel, char *direction) | ||
| 178 | { | ||
| 179 | char gpio_dir_file[128]; | ||
| 180 | int direction_fd=0; | ||
| 181 | int gpio_max; | ||
| 182 | int c; | ||
| 183 | |||
| 184 | gpio_max = gpio_base + nchannel; | ||
| 185 | for(c = gpio_base; c < gpio_max; c++) { | ||
| 186 | sprintf(gpio_dir_file, "/sys/class/gpio/gpio%d/direction",c); | ||
| 187 | direction_fd=open(gpio_dir_file, O_RDWR); | ||
| 188 | if (direction_fd < 0) { | ||
| 189 | fprintf(stderr, "Cannot open the direction file for GPIO %d\n", c); | ||
| 190 | return 1; | ||
| 191 | } | ||
| 192 | write(direction_fd, direction, (strlen(direction)+1)); | ||
| 193 | close(direction_fd); | ||
| 194 | } | ||
| 195 | return 0; | ||
| 196 | } | ||
| 197 | |||
| 198 | static int set_gpio_value(int gpio_base, int nchannel, int value) | ||
| 199 | { | ||
| 200 | char gpio_val_file[128]; | ||
| 201 | int val_fd=0; | ||
| 202 | int gpio_max; | ||
| 203 | char val_str[2]; | ||
| 204 | int c; | ||
| 205 | |||
| 206 | gpio_max = gpio_base + nchannel; | ||
| 207 | |||
| 208 | for(c = gpio_base; c < gpio_max; c++) { | ||
| 209 | sprintf(gpio_val_file, "/sys/class/gpio/gpio%d/value",c); | ||
| 210 | val_fd=open(gpio_val_file, O_RDWR); | ||
| 211 | if (val_fd < 0) { | ||
| 212 | fprintf(stderr, "Cannot open the value file of GPIO %d\n", c); | ||
| 213 | return -1; | ||
| 214 | } | ||
| 215 | sprintf(val_str,"%d", (value & 1)); | ||
| 216 | write(val_fd, val_str, sizeof(val_str)); | ||
| 217 | close(val_fd); | ||
| 218 | value >>= 1; | ||
| 219 | } | ||
| 220 | return 0; | ||
| 221 | } | ||
| 222 | |||
| 223 | static int get_gpio_value(int gpio_base, int nchannel) | ||
| 224 | { | ||
| 225 | char gpio_val_file[128]; | ||
| 226 | int val_fd=0; | ||
| 227 | int gpio_max; | ||
| 228 | char val_str[2]; | ||
| 229 | char *cptr; | ||
| 230 | int value = 0; | ||
| 231 | int c; | ||
| 232 | |||
| 233 | gpio_max = gpio_base + nchannel; | ||
| 234 | |||
| 235 | for(c = gpio_max-1; c >= gpio_base; c--) { | ||
| 236 | sprintf(gpio_val_file, "/sys/class/gpio/gpio%d/value",c); | ||
| 237 | val_fd=open(gpio_val_file, O_RDWR); | ||
| 238 | if (val_fd < 0) { | ||
| 239 | fprintf(stderr, "Cannot open GPIO to export %d\n", c); | ||
| 240 | return -1; | ||
| 241 | } | ||
| 242 | read(val_fd, val_str, sizeof(val_str)); | ||
| 243 | value <<= 1; | ||
| 244 | value += (int)strtoul(val_str, &cptr, 0); | ||
| 245 | if (cptr == optarg) { | ||
| 246 | fprintf(stderr, "Failed to change %s into integer", val_str); | ||
| 247 | } | ||
| 248 | close(val_fd); | ||
| 249 | } | ||
| 250 | return value; | ||
| 251 | } | ||
| 252 | |||
| 253 | void signal_handler(int sig) | ||
| 254 | { | ||
| 255 | switch (sig) { | ||
| 256 | case SIGTERM: | ||
| 257 | case SIGHUP: | ||
| 258 | case SIGQUIT: | ||
| 259 | case SIGINT: | ||
| 260 | close_gpio_channel(gl_gpio_base); | ||
| 261 | exit(0) ; | ||
| 262 | default: | ||
| 263 | break; | ||
| 264 | } | ||
| 265 | } | ||
| 266 | |||
| 267 | int main(int argc, char *argv[]) | ||
| 268 | { | ||
| 269 | extern char *optarg; | ||
| 270 | char *cptr; | ||
| 271 | int gpio_value = 0; | ||
| 272 | int nchannel = 0; | ||
| 273 | |||
| 274 | int c; | ||
| 275 | int i; | ||
| 276 | |||
| 277 | opterr = 0; | ||
| 278 | |||
| 279 | while ((c = getopt(argc, argv, "g:io:ck")) != -1) { | ||
| 280 | switch (c) { | ||
| 281 | case 'g': | ||
| 282 | gl_gpio_base = (int)strtoul(optarg, &cptr, 0); | ||
| 283 | if (cptr == optarg) | ||
| 284 | usage(argv[0]); | ||
| 285 | break; | ||
| 286 | case 'i': | ||
| 287 | gpio_opt = IN; | ||
| 288 | break; | ||
| 289 | case 'o': | ||
| 290 | gpio_opt = OUT; | ||
| 291 | gpio_value = (int)strtoul(optarg, &cptr, 0); | ||
| 292 | if (cptr == optarg) | ||
| 293 | usage(argv[0]); | ||
| 294 | break; | ||
| 295 | case 'c': | ||
| 296 | gpio_opt = CYLON; | ||
| 297 | break; | ||
| 298 | case 'k': | ||
| 299 | gpio_opt = KIT; | ||
| 300 | break; | ||
| 301 | case '?': | ||
| 302 | usage(argv[0]); | ||
| 303 | default: | ||
| 304 | usage(argv[0]); | ||
| 305 | |||
| 306 | } | ||
| 307 | } | ||
| 308 | |||
| 309 | if (gl_gpio_base == 0) { | ||
| 310 | usage(argv[0]); | ||
| 311 | } | ||
| 312 | |||
| 313 | nchannel = open_gpio_channel(gl_gpio_base); | ||
| 314 | signal(SIGTERM, signal_handler); /* catch kill signal */ | ||
| 315 | signal(SIGHUP, signal_handler); /* catch hang up signal */ | ||
| 316 | signal(SIGQUIT, signal_handler); /* catch quit signal */ | ||
| 317 | signal(SIGINT, signal_handler); /* catch a CTRL-c signal */ | ||
| 318 | switch (gpio_opt) { | ||
| 319 | case IN: | ||
| 320 | set_gpio_direction(gl_gpio_base, nchannel, "in"); | ||
| 321 | gpio_value=get_gpio_value(gl_gpio_base, nchannel); | ||
| 322 | fprintf(stdout,"0x%08X\n", gpio_value); | ||
| 323 | break; | ||
| 324 | case OUT: | ||
| 325 | set_gpio_direction(gl_gpio_base, nchannel, "out"); | ||
| 326 | set_gpio_value(gl_gpio_base, nchannel, gpio_value); | ||
| 327 | break; | ||
| 328 | case CYLON: | ||
| 329 | #define CYLON_DELAY_USECS (10000) | ||
| 330 | set_gpio_direction(gl_gpio_base, nchannel, "out"); | ||
| 331 | for (;;) { | ||
| 332 | for(i=0; i < ARRAY_SIZE(cylon); i++) { | ||
| 333 | gpio_value=(int)cylon[i]; | ||
| 334 | set_gpio_value(gl_gpio_base, nchannel, gpio_value); | ||
| 335 | } | ||
| 336 | usleep(CYLON_DELAY_USECS); | ||
| 337 | } | ||
| 338 | case KIT: | ||
| 339 | #define KIT_DELAY_USECS (10000) | ||
| 340 | set_gpio_direction(gl_gpio_base, nchannel, "out"); | ||
| 341 | for (;;) { | ||
| 342 | for (i=0; i<ARRAY_SIZE(kit); i++) { | ||
| 343 | gpio_value=(int)kit[i]; | ||
| 344 | set_gpio_value(gl_gpio_base, nchannel, gpio_value); | ||
| 345 | } | ||
| 346 | usleep(KIT_DELAY_USECS); | ||
| 347 | } | ||
| 348 | default: | ||
| 349 | break; | ||
| 350 | } | ||
| 351 | close_gpio_channel(gl_gpio_base); | ||
| 352 | return 0; | ||
| 353 | } | ||
| 354 | |||
| 355 | |||
diff --git a/meta-xilinx-demos/recipes-examples/gpio-demo/gpio-demo.bb b/meta-xilinx-demos/recipes-examples/gpio-demo/gpio-demo.bb new file mode 100644 index 00000000..912e0cd4 --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/gpio-demo/gpio-demo.bb | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | # | ||
| 2 | # This is the GPIO-DEMO apllication recipe | ||
| 3 | # | ||
| 4 | # | ||
| 5 | |||
| 6 | SUMMARY = "gpio-demo application" | ||
| 7 | SECTION = "PETALINUX/apps" | ||
| 8 | LICENSE = "MIT" | ||
| 9 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | ||
| 10 | SRC_URI = "file://gpio-demo.c \ | ||
| 11 | file://Makefile \ | ||
| 12 | " | ||
| 13 | S = "${WORKDIR}" | ||
| 14 | CFLAGS:prepend = "-I ${S}/include" | ||
| 15 | do_compile() { | ||
| 16 | oe_runmake | ||
| 17 | } | ||
| 18 | do_install() { | ||
| 19 | install -d ${D}${bindir} | ||
| 20 | install -m 0755 ${S}/gpio-demo ${D}${bindir} | ||
| 21 | |||
| 22 | } | ||
| 23 | |||
diff --git a/meta-xilinx-demos/recipes-examples/hellopm/files/hellopm.sh b/meta-xilinx-demos/recipes-examples/hellopm/files/hellopm.sh new file mode 100755 index 00000000..8b4dd75e --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/hellopm/files/hellopm.sh | |||
| @@ -0,0 +1,478 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | #******************************************************************************* | ||
| 4 | # | ||
| 5 | # Copyright (C) 2019 Xilinx, Inc. All rights reserved. | ||
| 6 | # Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved. | ||
| 7 | # | ||
| 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 9 | # this software and associated documentation files (the "Software"), to deal in | ||
| 10 | # the Software without restriction, including without limitation the rights to | ||
| 11 | # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
| 12 | # of the Software, and to permit persons to whom the Software is furnished to do | ||
| 13 | # so, subject to the following conditions: | ||
| 14 | # | ||
| 15 | # The above copyright notice and this permission notice shall be included in all | ||
| 16 | # copies or substantial portions of the Software. | ||
| 17 | # | ||
| 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 24 | # SOFTWARE. | ||
| 25 | # | ||
| 26 | # Author: Will Wong <willw@xilinx.com> | ||
| 27 | # | ||
| 28 | # ****************************************************************************** | ||
| 29 | |||
| 30 | # Xilinx Power Management Demo | ||
| 31 | |||
| 32 | # Stop on errors | ||
| 33 | set -e | ||
| 34 | |||
| 35 | suspend_menu () { | ||
| 36 | while true; do | ||
| 37 | cat <<-EOF | ||
| 38 | |||
| 39 | ++++++++++++++++++ | ||
| 40 | + Suspend/Resume + | ||
| 41 | ++++++++++++++++++ | ||
| 42 | |||
| 43 | EOF | ||
| 44 | |||
| 45 | cat <<-EOF | ||
| 46 | |||
| 47 | This operation suspends the kernel and powers off the processor. All | ||
| 48 | peripherals not used as a result of this operation will be powered | ||
| 49 | down or put into retention mode. (Note that peripherals that are still | ||
| 50 | being used by the RPU, such as memory, will not be powered down.) | ||
| 51 | |||
| 52 | If no peripherals on the FPD are being used as a result of this operation, | ||
| 53 | the FPD will be powered off. | ||
| 54 | |||
| 55 | While the processor is suspended, all the data and context information is | ||
| 56 | stored in the DRAM. If the FPD is powered off, the DRAM will be put into | ||
| 57 | self-refresh mode. | ||
| 58 | |||
| 59 | Options: | ||
| 60 | 1. Suspend now, wake-up on Real-time Clock (RTC) | ||
| 61 | 0. Go Back | ||
| 62 | |||
| 63 | EOF | ||
| 64 | echo -n "Input: " | ||
| 65 | read choice | ||
| 66 | echo "" | ||
| 67 | |||
| 68 | |||
| 69 | case $choice in | ||
| 70 | 0) | ||
| 71 | break | ||
| 72 | ;; | ||
| 73 | 1) | ||
| 74 | cat <<-EOF | ||
| 75 | |||
| 76 | Suspending now, wake-up on Real-time Clock (RTC) | ||
| 77 | |||
| 78 | Enable RTC as the wake-up source. | ||
| 79 | Command: echo +10 > /sys/class/rtc/rtc0/wakealarm | ||
| 80 | |||
| 81 | EOF | ||
| 82 | |||
| 83 | echo +10 > /sys/class/rtc/rtc0/wakealarm | ||
| 84 | |||
| 85 | cat <<-EOF | ||
| 86 | |||
| 87 | Invoke suspend sequence | ||
| 88 | Command: echo mem > /sys/power/state | ||
| 89 | Waking up in about 10 seconds ... | ||
| 90 | |||
| 91 | EOF | ||
| 92 | sleep 1 | ||
| 93 | echo mem > /sys/power/state | ||
| 94 | |||
| 95 | echo "Press RETURN to continue ..." | ||
| 96 | read dummy | ||
| 97 | ;; | ||
| 98 | esac | ||
| 99 | done | ||
| 100 | echo "" | ||
| 101 | } | ||
| 102 | |||
| 103 | |||
| 104 | cpu_hotplug_menu () { | ||
| 105 | while true; do | ||
| 106 | cat <<-EOF | ||
| 107 | +++++++++++++++ | ||
| 108 | + CPU Hotplug + | ||
| 109 | +++++++++++++++ | ||
| 110 | |||
| 111 | EOF | ||
| 112 | |||
| 113 | cat <<-EOF | ||
| 114 | This operation brings individual CPU cores online and offline. Processes | ||
| 115 | running on a CPU core will be moved over to another core before the core | ||
| 116 | is taken offline." | ||
| 117 | |||
| 118 | CPU Hotlplug is different from, but can be operating along with, CPU Idle. | ||
| 119 | The latter is having the kernel power off CPU cores when they are idling. | ||
| 120 | |||
| 121 | Options: | ||
| 122 | 1. Check CPU3 Status | ||
| 123 | 2. Take CPU3 Offline | ||
| 124 | 3. Bring CPU3 Online | ||
| 125 | 0. Go Back | ||
| 126 | |||
| 127 | EOF | ||
| 128 | echo -n "Input: " | ||
| 129 | read choice | ||
| 130 | echo "" | ||
| 131 | |||
| 132 | |||
| 133 | case $choice in | ||
| 134 | 0) | ||
| 135 | break | ||
| 136 | ;; | ||
| 137 | 1) | ||
| 138 | cat <<-EOF | ||
| 139 | Check CPU3 Status | ||
| 140 | |||
| 141 | Command: cat /sys/devices/system/cpu/cpu3/online | ||
| 142 | |||
| 143 | EOF | ||
| 144 | |||
| 145 | echo `cat /sys/devices/system/cpu/cpu3/online` | ||
| 146 | echo "" | ||
| 147 | echo "Press RETURN to continue ..." | ||
| 148 | read dummy | ||
| 149 | echo "" | ||
| 150 | ;; | ||
| 151 | 2) | ||
| 152 | cat <<-EOF | ||
| 153 | Take CPU3 Offline | ||
| 154 | |||
| 155 | Command: echo 0 > /sys/devices/system/cpu/cpu3/online | ||
| 156 | EOF | ||
| 157 | echo `echo 0 > /sys/devices/system/cpu/cpu3/online` | ||
| 158 | echo "" | ||
| 159 | echo "Press RETURN to continue ..." | ||
| 160 | read dummy | ||
| 161 | echo "" | ||
| 162 | ;; | ||
| 163 | 3) | ||
| 164 | cat <<-EOF | ||
| 165 | Bring CPU3 Online | ||
| 166 | |||
| 167 | Command: echo 1 > /sys/devices/system/cpu/cpu3/online | ||
| 168 | EOF | ||
| 169 | echo `echo 1 > /sys/devices/system/cpu/cpu3/online` | ||
| 170 | echo "" | ||
| 171 | echo "Press RETURN to continue ..." | ||
| 172 | read dummy | ||
| 173 | echo "" | ||
| 174 | ;; | ||
| 175 | esac | ||
| 176 | echo "" | ||
| 177 | done | ||
| 178 | } | ||
| 179 | |||
| 180 | cpu_freq_menu () { | ||
| 181 | while true; do | ||
| 182 | cat <<-EOF | ||
| 183 | ++++++++++++ | ||
| 184 | + CPU Freq + | ||
| 185 | ++++++++++++ | ||
| 186 | |||
| 187 | EOF | ||
| 188 | |||
| 189 | cat <<-EOF | ||
| 190 | This feature adjusts the CPU frequency on-the-fly. All CPU cores are running | ||
| 191 | at the same frequency. A lower CPU frequency consumes less power, at the | ||
| 192 | expense of performance. | ||
| 193 | |||
| 194 | The CPU frequency can be adjusted automatically by a governor, which controls | ||
| 195 | the CPU frequency based on its policy. A special 'userspace' governor does | ||
| 196 | not actually adjust the CPU frequency. Instead, it allows the users to | ||
| 197 | adjust the CPU frequency by themselves." | ||
| 198 | |||
| 199 | Options: | ||
| 200 | 1. Show current CPU frequency | ||
| 201 | 2. List supported CPU frequencies | ||
| 202 | 3. Change CPU frequency | ||
| 203 | 0. Go Back | ||
| 204 | |||
| 205 | EOF | ||
| 206 | echo -n "Input: " | ||
| 207 | read choice | ||
| 208 | echo "" | ||
| 209 | |||
| 210 | case $choice in | ||
| 211 | 0) | ||
| 212 | break | ||
| 213 | ;; | ||
| 214 | 1) | ||
| 215 | cat <<-EOF | ||
| 216 | Show current CPU frequency | ||
| 217 | |||
| 218 | Command: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq | ||
| 219 | EOF | ||
| 220 | |||
| 221 | echo `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` | ||
| 222 | echo "" | ||
| 223 | echo "Press RETURN to continue ..." | ||
| 224 | read dummy | ||
| 225 | echo "" | ||
| 226 | ;; | ||
| 227 | 2) | ||
| 228 | cat <<-EOF | ||
| 229 | List supported CPU frequencies | ||
| 230 | |||
| 231 | Command: cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies | ||
| 232 | EOF | ||
| 233 | |||
| 234 | echo `cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies` | ||
| 235 | echo "" | ||
| 236 | echo "Press RETURN to continue ..." | ||
| 237 | read dummy | ||
| 238 | echo "" | ||
| 239 | ;; | ||
| 240 | 3) | ||
| 241 | echo "Change CPU frequency" | ||
| 242 | echo "" | ||
| 243 | echo -n "Enter new frequency: " | ||
| 244 | read freq | ||
| 245 | echo "Command: echo $freq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed" | ||
| 246 | echo `echo $freq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed` | ||
| 247 | echo "" | ||
| 248 | echo "Press RETURN to continue ..." | ||
| 249 | read dummy | ||
| 250 | echo "" | ||
| 251 | ;; | ||
| 252 | esac | ||
| 253 | done | ||
| 254 | echo "" | ||
| 255 | } | ||
| 256 | |||
| 257 | reboot_menu () { | ||
| 258 | while true; do | ||
| 259 | cat <<-EOF | ||
| 260 | ++++++++++ | ||
| 261 | + Reboot + | ||
| 262 | ++++++++++ | ||
| 263 | |||
| 264 | EOF | ||
| 265 | |||
| 266 | cat <<-EOF | ||
| 267 | There are 3 types of reboot: APU-only, PS-only and System reboot. APU-only | ||
| 268 | reboot will only reboot the APU. The RPU, PMU and PL will not be affected. | ||
| 269 | |||
| 270 | PS-only reboot will reboot the PS, including the APU, RPU and PMU. | ||
| 271 | The PL will not be affected by a PS-only reboot, provided that the PL | ||
| 272 | is completely isolated from the PS. | ||
| 273 | |||
| 274 | System reboot will reboot the entire system, including the PS and the PL. | ||
| 275 | |||
| 276 | Options: | ||
| 277 | 1. Reboot APU | ||
| 278 | 2. Reboot PS | ||
| 279 | 3. Reboot System | ||
| 280 | 0. Go Back | ||
| 281 | |||
| 282 | EOF | ||
| 283 | echo -n "Input: " | ||
| 284 | read choice | ||
| 285 | echo "" | ||
| 286 | |||
| 287 | case $choice in | ||
| 288 | 0) | ||
| 289 | break | ||
| 290 | ;; | ||
| 291 | 1) | ||
| 292 | echo "Reboot APU" | ||
| 293 | echo "" | ||
| 294 | echo -n "This will end the demo. Continue (Y/n)? " | ||
| 295 | |||
| 296 | read continue | ||
| 297 | |||
| 298 | if [ "$continue" != "n" ] && [ "$continue" != "N" ]; then | ||
| 299 | cat <<-EOF | ||
| 300 | Set reboot scope to APU | ||
| 301 | Command: echo "subsystem" > /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope | ||
| 302 | EOF | ||
| 303 | echo `echo "subsystem" > /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope` | ||
| 304 | echo "" | ||
| 305 | echo "Command: reboot" | ||
| 306 | echo "" | ||
| 307 | reboot | ||
| 308 | while true; do | ||
| 309 | read dummy | ||
| 310 | done | ||
| 311 | fi | ||
| 312 | ;; | ||
| 313 | 2) | ||
| 314 | echo "Reboot PS" | ||
| 315 | echo "" | ||
| 316 | echo -n "This will end the demo. Continue (Y/n)? " | ||
| 317 | |||
| 318 | read continue | ||
| 319 | |||
| 320 | if [ "$continue" != "n" ] && [ "$continue" != "N" ]; then | ||
| 321 | cat <<-EOF | ||
| 322 | Set reboot scope to PS | ||
| 323 | Command: echo "ps_only" > /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope | ||
| 324 | EOF | ||
| 325 | echo `echo "ps_only" > /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope` | ||
| 326 | echo "" | ||
| 327 | |||
| 328 | echo "Command: reboot" | ||
| 329 | echo "" | ||
| 330 | reboot | ||
| 331 | while true; do | ||
| 332 | read dummy | ||
| 333 | done | ||
| 334 | fi | ||
| 335 | ;; | ||
| 336 | 3) | ||
| 337 | echo "Reboot System" | ||
| 338 | echo "" | ||
| 339 | echo -n "This will end the demo. Continue (Y/n)? " | ||
| 340 | |||
| 341 | read continue | ||
| 342 | echo "" | ||
| 343 | if [ "$continue" != "n" ] && [ "$continue" != "N" ]; then | ||
| 344 | cat <<-EOF | ||
| 345 | Set reboot scope to System | ||
| 346 | Command: echo "system" > /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope | ||
| 347 | EOF | ||
| 348 | |||
| 349 | echo `echo "system" > /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope` | ||
| 350 | echo "" | ||
| 351 | echo "Command: reboot" | ||
| 352 | echo "" | ||
| 353 | reboot | ||
| 354 | while true; do | ||
| 355 | read dummy | ||
| 356 | done | ||
| 357 | fi | ||
| 358 | ;; | ||
| 359 | esac | ||
| 360 | done | ||
| 361 | echo "" | ||
| 362 | } | ||
| 363 | |||
| 364 | shutdown_menu () { | ||
| 365 | while true; do | ||
| 366 | cat <<-EOF | ||
| 367 | ++++++++++++ | ||
| 368 | + Shutdown + | ||
| 369 | ++++++++++++ | ||
| 370 | |||
| 371 | EOF | ||
| 372 | |||
| 373 | cat <<-EOF | ||
| 374 | The command will shut down the APU. The RPU and PL will not be affected. | ||
| 375 | |||
| 376 | Options: | ||
| 377 | 1. Shutdown APU | ||
| 378 | 0. Go Back | ||
| 379 | |||
| 380 | EOF | ||
| 381 | |||
| 382 | echo -n "Input: " | ||
| 383 | read choice | ||
| 384 | echo "" | ||
| 385 | |||
| 386 | case $choice in | ||
| 387 | 0) | ||
| 388 | break | ||
| 389 | ;; | ||
| 390 | 1) | ||
| 391 | echo "Shutdown APU" | ||
| 392 | echo "" | ||
| 393 | echo -n "This will end the demo. Continue (Y/n)? " | ||
| 394 | read continue | ||
| 395 | echo "" | ||
| 396 | if [ "$continue" != "n" ] && [ "$continue" != "N" ]; then | ||
| 397 | echo "Command: shutdown -h now" | ||
| 398 | echo "" | ||
| 399 | shutdown -h now | ||
| 400 | while true; do | ||
| 401 | read dummy | ||
| 402 | done | ||
| 403 | fi | ||
| 404 | ;; | ||
| 405 | esac | ||
| 406 | done | ||
| 407 | echo "" | ||
| 408 | } | ||
| 409 | |||
| 410 | |||
| 411 | main_menu () { | ||
| 412 | while true; do | ||
| 413 | |||
| 414 | cat <<-EOF | ||
| 415 | |||
| 416 | +++++++++++++ | ||
| 417 | + Main Menu + | ||
| 418 | +++++++++++++ | ||
| 419 | |||
| 420 | EOF | ||
| 421 | |||
| 422 | cat <<-EOF | ||
| 423 | |||
| 424 | These are Linux-based power management features available for the | ||
| 425 | Zynq (c) UltraScale+ MPSoC. These examples assume you are using | ||
| 426 | the ZCU102 board, although most of them are independent of the | ||
| 427 | board type. | ||
| 428 | |||
| 429 | Options: | ||
| 430 | 1. Suspend/Resume | ||
| 431 | 2. CPU Hotplug | ||
| 432 | 3. CPU Freq | ||
| 433 | 4. Reboot | ||
| 434 | 5. Shutdown | ||
| 435 | 0. Quit | ||
| 436 | |||
| 437 | EOF | ||
| 438 | |||
| 439 | echo -n "Input: " | ||
| 440 | read choice | ||
| 441 | echo "" | ||
| 442 | |||
| 443 | case $choice in | ||
| 444 | 0) | ||
| 445 | break | ||
| 446 | ;; | ||
| 447 | 1) | ||
| 448 | suspend_menu | ||
| 449 | ;; | ||
| 450 | 2) | ||
| 451 | cpu_hotplug_menu | ||
| 452 | ;; | ||
| 453 | 3) | ||
| 454 | cpu_freq_menu | ||
| 455 | ;; | ||
| 456 | 4) | ||
| 457 | reboot_menu | ||
| 458 | ;; | ||
| 459 | 5) | ||
| 460 | shutdown_menu | ||
| 461 | |||
| 462 | esac | ||
| 463 | done | ||
| 464 | echo "" | ||
| 465 | } | ||
| 466 | |||
| 467 | echo "" | ||
| 468 | cat <<-EOF | ||
| 469 | ============================ | ||
| 470 | Hello PM World | ||
| 471 | Xilinx Power Management Demo | ||
| 472 | ============================ | ||
| 473 | EOF | ||
| 474 | echo "" | ||
| 475 | |||
| 476 | main_menu | ||
| 477 | echo "" | ||
| 478 | |||
diff --git a/meta-xilinx-demos/recipes-examples/hellopm/hellopm.bb b/meta-xilinx-demos/recipes-examples/hellopm/hellopm.bb new file mode 100644 index 00000000..4e788de4 --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/hellopm/hellopm.bb | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | # | ||
| 2 | # This recipe installs start script hellopm.sh in /usr/bin directory | ||
| 3 | # | ||
| 4 | |||
| 5 | DESCRIPTION = "This is a Power management Linux application which will allow user to do various operations such as suspend,wakeup,reboot,shutdown the system." | ||
| 6 | SUMMARY = "Hello PM Management Linux Application" | ||
| 7 | LICENSE = "Proprietary" | ||
| 8 | LIC_FILES_CHKSUM = "file://${WORKDIR}/hellopm.sh;beginline=3;endline=28;md5=bae95b94bf30629240b67f175cfd05ed" | ||
| 9 | |||
| 10 | COMPATIBLE_MACHINE = "^$" | ||
| 11 | COMPATIBLE_MACHINE:zynqmp = "zynqmp" | ||
| 12 | |||
| 13 | SRC_URI = "\ | ||
| 14 | file://hellopm.sh \ | ||
| 15 | " | ||
| 16 | |||
| 17 | S = "${WORKDIR}" | ||
| 18 | |||
| 19 | FILESEXTRAPATHS:prepend := "${THISDIR}/files:" | ||
| 20 | |||
| 21 | do_install() { | ||
| 22 | install -Dm 0755 ${S}/hellopm.sh ${D}${bindir}/hellopm | ||
| 23 | } | ||
| 24 | |||
| 25 | PACKAGE_ARCH = "${MACHINE_ARCH}" | ||
diff --git a/meta-xilinx-demos/recipes-examples/openamp/openamp-demo-notebooks_0.1.bb b/meta-xilinx-demos/recipes-examples/openamp/openamp-demo-notebooks_0.1.bb new file mode 100644 index 00000000..c95ec063 --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/openamp/openamp-demo-notebooks_0.1.bb | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | DESCRIPTION = "Jupyter notebooks for openAMP" | ||
| 2 | LICENSE = "BSD-3-Clause" | ||
| 3 | LIC_FILES_CHKSUM = "file://LICENSE;md5=268f2517fdae6d70f4ea4c55c4090aa8" | ||
| 4 | |||
| 5 | inherit jupyter-examples | ||
| 6 | |||
| 7 | REPO ?= "git://github.com/Xilinx/OpenAMP-notebooks.git;protocol=https" | ||
| 8 | SRCREV ?= "30b76d864261e5dd321fadfaf74b933b7cd88892" | ||
| 9 | BRANCH ?= "main" | ||
| 10 | BRANCHARG = "${@['nobranch=1', 'branch=${BRANCH}'][d.getVar('BRANCH') != '']}" | ||
| 11 | SRC_URI = "${REPO};${BRANCHARG}" | ||
| 12 | PV .= "+git" | ||
| 13 | S = "${WORKDIR}/git/openamp" | ||
| 14 | |||
| 15 | COMPATIBLE_MACHINE = "^$" | ||
| 16 | COMPATIBLE_MACHINE:zynqmp = "zynqmp" | ||
| 17 | COMPATIBLE_MACHINE:versal = "versal" | ||
| 18 | COMPATIBLE_MACHINE:versal-net = "versal-net" | ||
| 19 | |||
| 20 | DEPENDS += " packagegroup-petalinux-jupyter \ | ||
| 21 | packagegroup-openamp" | ||
| 22 | |||
| 23 | RDEPENDS:${PN} = " packagegroup-petalinux-jupyter \ | ||
| 24 | packagegroup-openamp" | ||
| 25 | |||
| 26 | do_install() { | ||
| 27 | install -d ${D}/${JUPYTER_DIR}/openamp-notebooks | ||
| 28 | install -d ${D}/${JUPYTER_DIR}/openamp-notebooks/pics | ||
| 29 | |||
| 30 | install -m 0755 ${S}/*.ipynb ${D}/${JUPYTER_DIR}/openamp-notebooks | ||
| 31 | install -m 0755 ${S}/pics/*.png ${D}/${JUPYTER_DIR}/openamp-notebooks/pics | ||
| 32 | } | ||
diff --git a/meta-xilinx-demos/recipes-examples/peekpoke/files/Makefile b/meta-xilinx-demos/recipes-examples/peekpoke/files/Makefile new file mode 100644 index 00000000..29fb5cdf --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/peekpoke/files/Makefile | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | PEEK = peek | ||
| 2 | POKE = poke | ||
| 3 | |||
| 4 | # Add any other object files to this list below | ||
| 5 | PEEK_OBJS = peek.o | ||
| 6 | POKE_OBJS = poke.o | ||
| 7 | |||
| 8 | all: $(PEEK) $(POKE) | ||
| 9 | |||
| 10 | $(POKE): $(POKE_OBJS) | ||
| 11 | $(CC) $(LDFLAGS) -o $@ $(POKE_OBJS) $(LDLIBS) | ||
| 12 | |||
| 13 | $(PEEK): $(PEEK_OBJS) | ||
| 14 | $(CC) $(LDFLAGS) -o $@ $(PEEK_OBJS) $(LDLIBS) | ||
| 15 | |||
| 16 | clean: | ||
| 17 | -rm -f $(POKE) $(PEEK) *.elf *.gdb *.o | ||
| 18 | |||
| 19 | |||
diff --git a/meta-xilinx-demos/recipes-examples/peekpoke/files/peek.c b/meta-xilinx-demos/recipes-examples/peekpoke/files/peek.c new file mode 100644 index 00000000..53bd1d1c --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/peekpoke/files/peek.c | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | /* | ||
| 2 | * peek utility - for those who remember the good old days! | ||
| 3 | * | ||
| 4 | * | ||
| 5 | * Copyright (C) 2013 - 2016 Xilinx, Inc. All rights reserved. | ||
| 6 | * | ||
| 7 | * Permission is hereby granted, free of charge, to any person | ||
| 8 | * obtaining a copy of this software and associated documentation | ||
| 9 | * files (the "Software"), to deal in the Software without restriction, | ||
| 10 | * including without limitation the rights to use, copy, modify, merge, | ||
| 11 | * publish, distribute, sublicense, and/or sell copies of the Software, | ||
| 12 | * and to permit persons to whom the Software is furnished to do so, | ||
| 13 | * subject to the following conditions: | ||
| 14 | * | ||
| 15 | * The above copyright notice and this permission notice shall be included | ||
| 16 | * in all copies or substantial portions of the Software. | ||
| 17 | * | ||
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| 21 | * IN NO EVENT SHALL XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
| 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 24 | * | ||
| 25 | * Except as contained in this notice, the name of the Xilinx shall not be used | ||
| 26 | * in advertising or otherwise to promote the sale, use or other dealings in this | ||
| 27 | * Software without prior written authorization from Xilinx. | ||
| 28 | * | ||
| 29 | */ | ||
| 30 | |||
| 31 | #include <stdio.h> | ||
| 32 | #include <stdlib.h> | ||
| 33 | #include <unistd.h> | ||
| 34 | #include <sys/mman.h> | ||
| 35 | #include <fcntl.h> | ||
| 36 | #include <stdint.h> | ||
| 37 | |||
| 38 | void usage(char *prog) | ||
| 39 | { | ||
| 40 | printf("usage: %s ADDR\n",prog); | ||
| 41 | printf("\n"); | ||
| 42 | printf("ADDR may be specified as hex values\n"); | ||
| 43 | } | ||
| 44 | |||
| 45 | |||
| 46 | int main(int argc, char *argv[]) | ||
| 47 | { | ||
| 48 | int fd; | ||
| 49 | void *ptr; | ||
| 50 | uint64_t addr, page_addr, page_offset; | ||
| 51 | uint64_t page_size=sysconf(_SC_PAGESIZE); | ||
| 52 | |||
| 53 | if(argc!=2) { | ||
| 54 | usage(argv[0]); | ||
| 55 | exit(-1); | ||
| 56 | } | ||
| 57 | |||
| 58 | fd=open("/dev/mem",O_RDONLY); | ||
| 59 | if(fd<1) { | ||
| 60 | perror(argv[0]); | ||
| 61 | exit(-1); | ||
| 62 | } | ||
| 63 | |||
| 64 | addr=strtoul(argv[1],NULL,0); | ||
| 65 | page_addr=(addr & ~(page_size-1)); | ||
| 66 | page_offset=addr-page_addr; | ||
| 67 | |||
| 68 | ptr=mmap(NULL,page_size,PROT_READ,MAP_SHARED,fd,(addr & ~(page_size-1))); | ||
| 69 | if((int64_t)ptr==-1) { | ||
| 70 | perror(argv[0]); | ||
| 71 | exit(-1); | ||
| 72 | } | ||
| 73 | |||
| 74 | printf("0x%08lx\n",*((uint64_t *)(ptr+page_offset))); | ||
| 75 | return 0; | ||
| 76 | } | ||
diff --git a/meta-xilinx-demos/recipes-examples/peekpoke/files/poke.c b/meta-xilinx-demos/recipes-examples/peekpoke/files/poke.c new file mode 100644 index 00000000..6948bca7 --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/peekpoke/files/poke.c | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | /* | ||
| 2 | * poke utility - for those who remember the good old days! | ||
| 3 | * Fixed by Pascal Bos from Nikhef, to be able to use this | ||
| 4 | * in 64 bit registers. | ||
| 5 | * | ||
| 6 | * Copyright (C) 2013 - 2016 Xilinx, Inc. All rights reserved. | ||
| 7 | * | ||
| 8 | * Permission is hereby granted, free of charge, to any person | ||
| 9 | * obtaining a copy of this software and associated documentation | ||
| 10 | * files (the "Software"), to deal in the Software without restriction, | ||
| 11 | * including without limitation the rights to use, copy, modify, merge, | ||
| 12 | * publish, distribute, sublicense, and/or sell copies of the Software, | ||
| 13 | * and to permit persons to whom the Software is furnished to do so, | ||
| 14 | * subject to the following conditions: | ||
| 15 | * | ||
| 16 | * The above copyright notice and this permission notice shall be included | ||
| 17 | * in all copies or substantial portions of the Software. | ||
| 18 | * | ||
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| 22 | * IN NO EVENT SHALL XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
| 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 25 | * | ||
| 26 | * Except as contained in this notice, the name of the Xilinx shall not be used | ||
| 27 | * in advertising or otherwise to promote the sale, use or other dealings in this | ||
| 28 | * Software without prior written authorization from Xilinx. | ||
| 29 | * | ||
| 30 | */ | ||
| 31 | |||
| 32 | #include <stdio.h> | ||
| 33 | #include <stdlib.h> | ||
| 34 | #include <unistd.h> | ||
| 35 | #include <stdint.h> | ||
| 36 | #include <sys/mman.h> | ||
| 37 | #include <fcntl.h> | ||
| 38 | |||
| 39 | void usage(char *prog) | ||
| 40 | { | ||
| 41 | printf("usage: %s ADDR VAL\n",prog); | ||
| 42 | printf("\n"); | ||
| 43 | printf("ADDR and VAL may be specified as hex values\n"); | ||
| 44 | } | ||
| 45 | |||
| 46 | int main(int argc, char *argv[]) | ||
| 47 | { | ||
| 48 | int fd; | ||
| 49 | void *ptr; | ||
| 50 | uint64_t val; | ||
| 51 | uint64_t addr, page_addr, page_offset; | ||
| 52 | uint64_t page_size=sysconf(_SC_PAGESIZE); | ||
| 53 | |||
| 54 | fd=open("/dev/mem",O_RDWR); | ||
| 55 | if(fd<1) { | ||
| 56 | perror(argv[0]); | ||
| 57 | exit(-1); | ||
| 58 | } | ||
| 59 | |||
| 60 | if(argc!=3) { | ||
| 61 | usage(argv[0]); | ||
| 62 | exit(-1); | ||
| 63 | } | ||
| 64 | |||
| 65 | addr=strtoul(argv[1],NULL,0); | ||
| 66 | val=strtoul(argv[2],NULL,0); | ||
| 67 | |||
| 68 | page_addr=(addr & ~(page_size-1)); | ||
| 69 | page_offset=addr-page_addr; | ||
| 70 | |||
| 71 | ptr=mmap(NULL,page_size,PROT_READ|PROT_WRITE,MAP_SHARED,fd,(addr & ~(page_size-1))); | ||
| 72 | if((int64_t)ptr==-1) { | ||
| 73 | perror(argv[0]); | ||
| 74 | exit(-1); | ||
| 75 | } | ||
| 76 | |||
| 77 | *((uint64_t *)(ptr+page_offset))=val; | ||
| 78 | return 0; | ||
| 79 | } | ||
diff --git a/meta-xilinx-demos/recipes-examples/peekpoke/peekpoke.bb b/meta-xilinx-demos/recipes-examples/peekpoke/peekpoke.bb new file mode 100644 index 00000000..3949598e --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/peekpoke/peekpoke.bb | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | # | ||
| 2 | # This is the peekpoke apllication recipe | ||
| 3 | # | ||
| 4 | # | ||
| 5 | |||
| 6 | SUMMARY = "peekpoke application" | ||
| 7 | SECTION = "PETALINUX/apps" | ||
| 8 | LICENSE = "MIT" | ||
| 9 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | ||
| 10 | SRC_URI = "file://peek.c \ | ||
| 11 | file://poke.c \ | ||
| 12 | file://Makefile \ | ||
| 13 | " | ||
| 14 | S = "${WORKDIR}" | ||
| 15 | CFLAGS:prepend = "-I ${S}/include" | ||
| 16 | do_compile() { | ||
| 17 | oe_runmake | ||
| 18 | } | ||
| 19 | do_install() { | ||
| 20 | install -d ${D}${bindir} | ||
| 21 | install -m 0755 ${S}/peek ${D}${bindir} | ||
| 22 | install -m 0755 ${S}/poke ${D}${bindir} | ||
| 23 | |||
| 24 | } | ||
| 25 | |||
diff --git a/meta-xilinx-demos/recipes-examples/pm-notebooks/files/LICENSE b/meta-xilinx-demos/recipes-examples/pm-notebooks/files/LICENSE new file mode 100644 index 00000000..e09f3af7 --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/pm-notebooks/files/LICENSE | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | Copyright (c) 2019, Xilinx | ||
| 2 | All rights reserved. | ||
| 3 | |||
| 4 | Redistribution and use in source and binary forms, with or without | ||
| 5 | modification, are permitted provided that the following conditions are met: | ||
| 6 | |||
| 7 | * Redistributions of source code must retain the above copyright notice, this | ||
| 8 | list of conditions and the following disclaimer. | ||
| 9 | |||
| 10 | * Redistributions in binary form must reproduce the above copyright notice, | ||
| 11 | this list of conditions and the following disclaimer in the documentation | ||
| 12 | and/or other materials provided with the distribution. | ||
| 13 | |||
| 14 | * Neither the name of the copyright holder nor the names of its | ||
| 15 | contributors may be used to endorse or promote products derived from | ||
| 16 | this software without specific prior written permission. | ||
| 17 | |||
| 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
diff --git a/meta-xilinx-demos/recipes-examples/pm-notebooks/pm-notebooks_1.0.bb b/meta-xilinx-demos/recipes-examples/pm-notebooks/pm-notebooks_1.0.bb new file mode 100644 index 00000000..cae62b14 --- /dev/null +++ b/meta-xilinx-demos/recipes-examples/pm-notebooks/pm-notebooks_1.0.bb | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | DESCRIPTION = "Jupyter notebook examples for Platform Management (PM) in Versal devices" | ||
| 2 | LICENSE = "BSD-3-Clause" | ||
| 3 | LIC_FILES_CHKSUM = "file://../../LICENSE;md5=268f2517fdae6d70f4ea4c55c4090aa8" | ||
| 4 | |||
| 5 | inherit jupyter-examples | ||
| 6 | |||
| 7 | SRC_URI = "git://github.com/Xilinx/platform-management-notebooks.git;branch=xlnx_rel_v2023.2;protocol=https \ | ||
| 8 | file://LICENSE \ | ||
| 9 | " | ||
| 10 | |||
| 11 | SRCREV = "c502be361b6857e21ab903f31c9ead69e3a0d9ba" | ||
| 12 | |||
| 13 | S = "${WORKDIR}/git/pm-notebooks" | ||
| 14 | |||
| 15 | COMPATIBLE_MACHINE = "^$" | ||
| 16 | COMPATIBLE_MACHINE:versal = "versal" | ||
| 17 | COMPATIBLE_MACHINE:versal-net = "versal-net" | ||
| 18 | |||
| 19 | RDEPENDS:${PN} = " \ | ||
| 20 | packagegroup-petalinux-jupyter \ | ||
| 21 | python3-ipywidgets \ | ||
| 22 | python3-pydot \ | ||
| 23 | graphviz \ | ||
| 24 | " | ||
| 25 | |||
| 26 | do_install() { | ||
| 27 | install -d ${D}/${JUPYTER_DIR}/pm-notebooks | ||
| 28 | install -d ${D}/${JUPYTER_DIR}/pm-notebooks/pmutil | ||
| 29 | install -d ${D}/${JUPYTER_DIR}/pm-notebooks/pmutil/data | ||
| 30 | |||
| 31 | install -m 0644 ${S}/README ${D}/${JUPYTER_DIR}/pm-notebooks | ||
| 32 | install -m 0755 ${S}/*.ipynb ${D}/${JUPYTER_DIR}/pm-notebooks | ||
| 33 | install -m 0755 ${S}/pmutil/*.py ${D}/${JUPYTER_DIR}/pm-notebooks/pmutil | ||
| 34 | install -m 0755 ${S}/pmutil/data/*.png ${D}/${JUPYTER_DIR}/pm-notebooks/pmutil/data | ||
| 35 | } | ||
| 36 | |||
