Contact Form

Name

Email *

Message *

Search This Blog

Total Pageviews

Popular Posts

Translate

Sunday, November 14, 2021

Proof Of Concept: Initial integration of ficl into Zephyr

 I haven't been talking much lately, due to my diagnosis of Myasthenia Gravis and life's distractions, but since I'm planning on talking at Forth Day this year, this is an easy place to throw some notes.

Proof Of Concept: Initial integration of ficl into Zephyr

The Zephyr OS is a small-footprint kernel designed for use on resource-constrained and embedded systems. Integrating the Forth Inspired Command Language (ficl) provides an alternative, extensible diagnostic capability.

I have not gotten permission from my employer yet, so I will not mention them until I do, but I can mention the public recognition that I did receive for contributions to the Zephyr project:

"The Zephyr® Project strives to deliver the best-in-class RTOS for connected resource-constrained devices, built to be secure and safe." It has been an interesting adventure working with this group and all you have to do is get a pull request accepted by them to get this badge, but I shouldn't minimize the effort required to get their acceptance. I don't have any other open source projects where I have attempted to be this active, and trying to do this with a Forth project should prove to be even more interesting.

A friend of mine from when we worked at Apple got me this job, and he even promoted Forth as he introduced me to them, but for the most part, I've been too busy with my actual job to get much done with Forth yet. I tend to work at the intersection of hardware and software, so getting drivers written for all of the IoT devices we intend on using takes priority over "playing" with Forth.

The actual project I'm working existed when I started, using different hardware and we went through a couple iterations before we ended with with Zephyr running on a Silicon Labs EFM32 Pearl Gecko Starter Kit.

We were using Simplicity Studio before we jumped into Zephyr and I had an initial version of ficl running there:

ficl - Run the Forth Inspired Command Language
Usage: ficl
%: ficl

ok>

However, it did not do much of anything there and it was buried inside our proprietary code, so I can't even show you anything about how I accomplished that.

On Zephyr, I have the advantage of it being open source and it has a native_posix interface that made this initial POC relatively simple to accomplish in 1 day.

west build -b native_posix ../zephyr-tmo-sdk/modules/ficl/
...
./build/zephyr/zephyr.exe
*** Booting Zephyr OS build v2.6.0-rc2-124-gc8ccacef8f82  ***
loading CORE EXT words 
loading SEARCH & SEARCH-EXT words 
loading Johns-Hopkins locals 
loading MARKER 
loading ficl O-O extensions 
loading ficl utility classes 
loading ficl string class 
Ficl version 4.1.0
Nov 14 2021 
ok> 5 . 
5 ok> 

 The hardest part of this integration was described here: Using static libraries on a Zephyr RTOS Project. So, it was easy enough to come up with the following CMakeLists.txt test case:

# Copyright (c) 2021 Dennis Ruffer <daruffer@gmail.com>
#
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(ficl)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
target_sources(app PRIVATE src/ficlplatform/unix.c)
target_sources(app PRIVATE src/softcore.c)

There are a bunch of edits within ficl that I have to resolve and probably post back to it's source forge home and I found out I am dealing with 2 different versions:

$Id: main.c,v 1.3 2010/11/01 14:10:27 asau Exp $
$Id: main.c,v 1.2 2010/09/10 09:01:28 asau Exp $

Both of which are called FICL 4.1.0 October 2010, so there's some work to do there too.

You may also notice that the output came out on the terminal command line, rather than the serial port where everything is actually supposed to go, but it's a 1st step. More is yet to come at some later date.

Thanks for listening!

DaR


Friday, February 22, 2019

ESP32 SDMMC Interface

This is a place to collect information about setting up an SD card on an ESP32 chip

 

FireBeetle ESP32 IOT Microcontroller (Supports Wi-Fi & Bluetooth) 
https://www.dfrobot.com/product-1590.html

Gravity: Triple Axis Accelerometer MMA7361
https://www.dfrobot.com/product-507.html

RCWL-0516 microwave radar sensor module
https://alexnld.com/product/rcwl-0516-rcwl-0516-microwave-radar-sensor-human-sensor-body-sensor-module-induction-switch-module-output-3-3v/

Switch Science SparkFun SD Card Slot Pitch Conversion Board
https://www.amazon.com/Switch-Science-SparkFun-Pitch-Conversion/dp/B0105QIV3Q

Only needed pull-up on D0
https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/sd_pullup_requirements.html

Microsoft has set a 32GB partition size limit for the FAT/FAT32 file system to promote NTFS, which is generally more efficient when working with large partitions.”
http://www.ridgecrop.demon.co.uk/index.htm?guiformat.htm


These 2 lines must be commented out:
//    Serial.printf("Total space: %lluMB\n", SD_MMC.totalBytes() / (1024 * 1024));
//    Serial.printf("Used space: %lluMB\n", SD_MMC.usedBytes() / (1024 * 1024));

Obsolete functions?

ets Jun  8 2016 00:22:57
14:52:48.096 ->
14:52:48.096 -> rst:0x1 (POWERON_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57
14:52:48.440 ->
14:52:48.440 -> rst:0x10 (RTCWDT_RTC_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
14:52:48.474 -> configsip: 0, SPIWP:0x00
14:52:48.474 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
14:52:48.474 -> mode:DIO, clock div:1
14:52:48.474 -> load:0x3fff0008,len:8
14:52:48.474 -> load:0x3fff0010,len:1760
14:52:48.474 -> load:0x40078000,len:6668
14:52:48.474 -> load:0x40080000,len:252
14:52:48.474 -> entry 0x40080034
SD_MMC Card Type: SDHC
14:52:48.714 -> SD_MMC Card Size: 30436MB
14:52:48.714 -> Listing directory: /
14:52:48.714 ->   DIR : /System Volume Information
14:52:48.714 ->   FILE: /riscos-boot.bin  SIZE: 9728
14:52:48.714 ->   DIR : /defaults
14:52:48.714 ->   DIR : /os
14:52:48.714 ->   DIR : /overlays
14:52:48.748 ->   FILE: /bcm2708-rpi-0-w.dtb  SIZE: 22264
14:52:48.748 ->   FILE: /bcm2708-rpi-b.dtb  SIZE: 21761
14:52:48.748 ->   FILE: /bcm2708-rpi-b-plus.dtb  SIZE: 22020
14:52:48.748 ->   FILE: /bcm2708-rpi-cm.dtb  SIZE: 21474
14:52:48.748 ->   FILE: /bcm2709-rpi-2-b.dtb  SIZE: 23044
14:52:48.748 ->   FILE: /bcm2710-rpi-3-b.dtb  SIZE: 24240
14:52:48.748 ->   FILE: /bcm2710-rpi-3-b-plus.dtb  SIZE: 24503
14:52:48.748 ->   FILE: /bcm2710-rpi-cm3.dtb  SIZE: 22952
14:52:48.748 ->   FILE: /bootcode.bin  SIZE: 52064
14:52:48.748 ->   FILE: /BUILD-DATA  SIZE: 303
14:52:48.782 ->   FILE: /INSTRUCTIONS-README.txt  SIZE: 2356
14:52:48.782 ->   FILE: /recovery.cmdline  SIZE: 85
14:52:48.782 ->   FILE: /recovery.elf  SIZE: 673444
14:52:48.782 ->   FILE: /recovery.img  SIZE: 2987384
14:52:48.782 ->   FILE: /recovery.rfs  SIZE: 28565504
14:52:48.782 ->   FILE: /RECOVERY_FILES_DO_NOT_EDIT  SIZE: 0
14:52:48.782 ->   FILE: /recovery7.img  SIZE: 3052536
14:52:48.782 ->   FILE: /test.txt  SIZE: 1048576
14:52:48.782 ->   FILE: /foo.txt  SIZE: 13
14:52:48.816 -> Creating Dir: /mydir
14:52:48.816 -> Dir created
14:52:48.816 -> Listing directory: /
14:52:48.816 ->   DIR : /System Volume Information
14:52:48.816 ->   FILE: /riscos-boot.bin  SIZE: 9728
14:52:48.850 ->   DIR : /defaults
14:52:48.850 ->   DIR : /os
14:52:48.850 ->   DIR : /overlays
14:52:48.850 ->   FILE: /bcm2708-rpi-0-w.dtb  SIZE: 22264
14:52:48.850 ->   FILE: /bcm2708-rpi-b.dtb  SIZE: 21761
14:52:48.850 ->   FILE: /bcm2708-rpi-b-plus.dtb  SIZE: 22020
14:52:48.850 ->   FILE: /bcm2708-rpi-cm.dtb  SIZE: 21474
14:52:48.850 ->   FILE: /bcm2709-rpi-2-b.dtb  SIZE: 23044
14:52:48.850 ->   FILE: /bcm2710-rpi-3-b.dtb  SIZE: 24240
14:52:48.850 ->   FILE: /bcm2710-rpi-3-b-plus.dtb  SIZE: 24503
14:52:48.850 ->   FILE: /bcm2710-rpi-cm3.dtb  SIZE: 22952
14:52:48.850 ->   FILE: /bootcode.bin  SIZE: 52064
14:52:48.885 ->   FILE: /BUILD-DATA  SIZE: 303
14:52:48.885 ->   FILE: /INSTRUCTIONS-README.txt  SIZE: 2356
14:52:48.885 ->   FILE: /recovery.cmdline  SIZE: 85
14:52:48.885 ->   FILE: /recovery.elf  SIZE: 673444
14:52:48.885 ->   FILE: /recovery.img  SIZE: 2987384
14:52:48.885 ->   FILE: /recovery.rfs  SIZE: 28565504
14:52:48.885 ->   FILE: /RECOVERY_FILES_DO_NOT_EDIT  SIZE: 0
14:52:48.885 ->   FILE: /recovery7.img  SIZE: 3052536
14:52:48.885 ->   FILE: /test.txt  SIZE: 1048576
14:52:48.919 ->   FILE: /foo.txt  SIZE: 13
14:52:48.919 ->   DIR : /mydir
14:52:48.919 -> Removing Dir: /mydir
14:52:48.919 -> Dir removed
14:52:48.919 -> Listing directory: /
14:52:48.919 ->   DIR : /System Volume Information
14:52:48.919 -> Listing directory: /System Volume Information
14:52:48.919 ->   FILE: /System Volume Information/IndexerVolumeGuid  SIZE: 76
14:52:48.919 ->   FILE: /riscos-boot.bin  SIZE: 9728
14:52:48.919 ->   DIR : /defaults
14:52:48.919 -> Listing directory: /defaults
14:52:48.919 ->   DIR : /defaults/slides
14:52:48.919 -> Listing directory: /defaults/slides
14:52:48.953 ->   FILE: /defaults/slides/A.PNG  SIZE: 40113
14:52:48.953 ->   DIR : /os
14:52:48.953 -> Listing directory: /os
14:52:48.953 ->   DIR : /os/LibreELEC_RPi
14:52:48.953 -> Listing directory: /os/LibreELEC_RPi
14:52:48.953 ->   FILE: /os/LibreELEC_RPi/LibreELEC_RPi.png  SIZE: 840
14:52:48.953 ->   FILE: /os/LibreELEC_RPi/os.json  SIZE: 432
14:52:48.953 ->   FILE: /os/LibreELEC_RPi/partitions.json  SIZE: 545
14:52:48.953 ->   FILE: /os/LibreELEC_RPi/partition_setup.sh  SIZE: 2284
14:52:48.953 ->   FILE: /os/LibreELEC_RPi/README.MD  SIZE: 1946
14:52:48.988 ->   FILE: /os/LibreELEC_RPi/release_notes.txt  SIZE: 429
14:52:48.988 ->   FILE: /os/LibreELEC_RPi/Storage.tar.xz  SIZE: 168
14:52:48.988 ->   FILE: /os/LibreELEC_RPi/System.tar.xz  SIZE: 117099424
14:52:48.988 ->   DIR : /os/LibreELEC_RPi/slides
14:52:48.988 ->   DIR : /os/LibreELEC_RPi/slides_vga
14:52:48.988 ->   DIR : /os/LibreELEC_RPi2
14:52:48.988 -> Listing directory: /os/LibreELEC_RPi2
14:52:48.988 ->   FILE: /os/LibreELEC_RPi2/LibreELEC_RPi2.png  SIZE: 840
14:52:48.988 ->   FILE: /os/LibreELEC_RPi2/os.json  SIZE: 374
14:52:48.988 ->   FILE: /os/LibreELEC_RPi2/partitions.json  SIZE: 545
14:52:49.023 ->   FILE: /os/LibreELEC_RPi2/partition_setup.sh  SIZE: 2284
14:52:49.023 ->   FILE: /os/LibreELEC_RPi2/README.MD  SIZE: 1946
14:52:49.023 ->   FILE: /os/LibreELEC_RPi2/release_notes.txt  SIZE: 429
14:52:49.023 ->   FILE: /os/LibreELEC_RPi2/Storage.tar.xz  SIZE: 168
14:52:49.023 ->   FILE: /os/LibreELEC_RPi2/System.tar.xz  SIZE: 117044060
14:52:49.023 ->   DIR : /os/LibreELEC_RPi2/slides
14:52:49.058 ->   DIR : /os/LibreELEC_RPi2/slides_vga
14:52:49.058 ->   DIR : /os/Raspbian
14:52:49.058 -> Listing directory: /os/Raspbian
14:52:49.058 ->   FILE: /os/Raspbian/boot.tar.xz  SIZE: 13132916
14:52:49.058 ->   FILE: /os/Raspbian/os.json  SIZE: 424
14:52:49.058 ->   FILE: /os/Raspbian/partitions.json  SIZE: 537
14:52:49.058 ->   FILE: /os/Raspbian/partition_setup.sh  SIZE: 745
14:52:49.058 ->   FILE: /os/Raspbian/Raspbian.png  SIZE: 1662
14:52:49.058 ->   FILE: /os/Raspbian/release_notes.txt  SIZE: 14150
14:52:49.058 ->   FILE: /os/Raspbian/root.tar.xz  SIZE: 1294957924
14:52:49.092 ->   DIR : /os/Raspbian/slides_vga
14:52:49.092 ->   DIR : /overlays
14:52:49.092 -> Listing directory: /overlays
14:52:49.092 ->   FILE: /overlays/adau1977-adc.dtbo  SIZE: 1027
14:52:49.092 ->   FILE: /overlays/adau7002-simple.dtbo  SIZE: 1587
14:52:49.092 ->   FILE: /overlays/ads1015.dtbo  SIZE: 2425
14:52:49.092 ->   FILE: /overlays/ads1115.dtbo  SIZE: 2425
14:52:49.092 ->   FILE: /overlays/ads7846.dtbo  SIZE: 2426
14:52:49.092 ->   FILE: /overlays/akkordion-iqdacplus.dtbo  SIZE: 1387
14:52:49.092 ->   FILE: /overlays/allo-boss-dac-pcm512x-audio.dtbo  SIZE: 1473
14:52:49.126 ->   FILE: /overlays/allo-digione.dtbo  SIZE: 1208
14:52:49.126 ->   FILE: /overlays/allo-piano-dac-pcm512x-audio.dtbo  SIZE: 1011
14:52:49.126 ->   FILE: /overlays/allo-piano-dac-plus-pcm512x-audio.dtbo  SIZE: 1585
14:52:49.126 ->   FILE: /overlays/applepi-dac.dtbo  SIZE: 1454
14:52:49.126 ->   FILE: /overlays/at86rf233.dtbo  SIZE: 1668
14:52:49.126 ->   FILE: /overlays/audioinjector-addons.dtbo  SIZE: 2144
14:52:49.126 ->   FILE: /overlays/audioinjector-wm8731-audio.dtbo  SIZE: 787
14:52:49.161 ->   FILE: /overlays/audremap.dtbo  SIZE: 575
14:52:49.161 ->   FILE: /overlays/bmp085_i2c-sensor.dtbo  SIZE: 449
14:52:49.161 ->   FILE: /overlays/dht11.dtbo  SIZE: 983
14:52:49.161 ->   FILE: /overlays/dionaudio-loco-v2.dtbo  SIZE: 1027
14:52:49.161 ->   FILE: /overlays/dionaudio-loco.dtbo  SIZE: 663
14:52:49.161 ->   FILE: /overlays/dpi18.dtbo  SIZE: 765
14:52:49.161 ->   FILE: /overlays/dpi24.dtbo  SIZE: 789
14:52:49.195 ->   FILE: /overlays/dwc-otg.dtbo  SIZE: 423
14:52:49.195 ->   FILE: /overlays/dwc2.dtbo  SIZE: 856
14:52:49.195 ->   FILE: /overlays/enc28j60-spi2.dtbo  SIZE: 1279
14:52:49.195 ->   FILE: /overlays/enc28j60.dtbo  SIZE: 1403
14:52:49.195 ->   FILE: /overlays/exc3000.dtbo  SIZE: 1562
14:52:49.195 ->   FILE: /overlays/fe-pi-audio.dtbo  SIZE: 1932
14:52:49.195 ->   FILE: /overlays/goodix.dtbo  SIZE: 1437
14:52:49.195 ->   FILE: /overlays/googlevoicehat-soundcard.dtbo  SIZE: 1259
14:52:49.195 ->   FILE: /overlays/gpio-ir-tx.dtbo  SIZE: 1096
14:52:49.230 ->   FILE: /overlays/gpio-ir.dtbo  SIZE: 1212
14:52:49.230 ->   FILE: /overlays/gpio-key.dtbo  SIZE: 1373
14:52:49.230 ->   FILE: /overlays/gpio-poweroff.dtbo  SIZE: 901
14:52:49.230 ->   FILE: /overlays/gpio-shutdown.dtbo  SIZE: 1250
14:52:49.230 ->   FILE: /overlays/hifiberry-amp.dtbo  SIZE: 779
14:52:49.230 ->   FILE: /overlays/hifiberry-dac.dtbo  SIZE: 655
14:52:49.230 ->   FILE: /overlays/hifiberry-dacplus.dtbo  SIZE: 1693
14:52:49.230 ->   FILE: /overlays/hifiberry-digi-pro.dtbo  SIZE: 1125
14:52:49.265 ->   FILE: /overlays/hifiberry-digi.dtbo  SIZE: 959
14:52:49.265 ->   FILE: /overlays/hy28a.dtbo  SIZE: 2468
14:52:49.265 ->   FILE: /overlays/hy28b.dtbo  SIZE: 2939
14:52:49.265 ->   FILE: /overlays/i2c-bcm2708.dtbo  SIZE: 270
14:52:49.265 ->   FILE: /overlays/i2c-gpio.dtbo  SIZE: 1035
14:52:49.265 ->   FILE: /overlays/i2c-mux.dtbo  SIZE: 2185
14:52:49.265 ->   FILE: /overlays/i2c-pwm-pca9685a.dtbo  SIZE: 644
14:52:49.300 ->   FILE: /overlays/i2c-rtc-gpio.dtbo  SIZE: 4143
14:52:49.300 ->   FILE: /overlays/i2c-rtc.dtbo  SIZE: 3765
14:52:49.300 ->   FILE: /overlays/i2c-sensor.dtbo  SIZE: 4402
14:52:49.300 ->   FILE: /overlays/i2c0-bcm2708.dtbo  SIZE: 1182
14:52:49.300 ->   FILE: /overlays/i2c1-bcm2708.dtbo  SIZE: 805
14:52:49.300 ->   FILE: /overlays/i2s-gpio28-31.dtbo  SIZE: 343
14:52:49.334 ->   FILE: /overlays/iqaudio-dac.dtbo  SIZE: 1272
14:52:49.334 ->   FILE: /overlays/iqaudio-dacplus.dtbo  SIZE: 1511
14:52:49.334 ->   FILE: /overlays/iqaudio-digi-wm8804-audio.dtbo  SIZE: 1326
14:52:49.334 ->   FILE: /overlays/jedec-spi-nor.dtbo  SIZE: 5212
14:52:49.334 ->   FILE: /overlays/justboom-dac.dtbo  SIZE: 1276
14:52:49.368 ->   FILE: /overlays/justboom-digi.dtbo  SIZE: 955
14:52:49.368 ->   FILE: /overlays/lirc-rpi.dtbo  SIZE: 1348
14:52:49.368 ->   FILE: /overlays/mbed-dac.dtbo  SIZE: 1605
14:52:49.368 ->   FILE: /overlays/mcp23017.dtbo  SIZE: 1329
14:52:49.368 ->   FILE: /overlays/mcp23s17.dtbo  SIZE: 15229
  FILE: /overlays/mcp2515-can0.dtbo  SIZE: 1833
14:52:49.403 ->   FILE: /overlays/mcp2515-can1.dtbo  SIZE: 1833
14:52:49.403 ->   FILE: /overlays/mcp3008.dtbo  SIZE: 4237
14:52:49.403 ->   FILE: /overlays/mcp3202.dtbo  SIZE: 4237
14:52:49.403 ->   FILE: /overlays/media-center.dtbo  SIZE: 3438
14:52:49.438 ->   FILE: /overlays/midi-uart0.dtbo  SIZE: 720
14:52:49.438 ->   FILE: /overlays/midi-uart1.dtbo  SIZE: 857
14:52:49.438 ->   FILE: /overlays/mmc.dtbo  SIZE: 1099
14:52:49.438 ->   FILE: /overlays/mpu6050.dtbo  SIZE: 796
14:52:49.438 ->   FILE: /overlays/mz61581.dtbo  SIZE: 2850
14:52:49.472 ->   FILE: /overlays/papirus.dtbo  SIZE: 2356
14:52:49.472 ->   FILE: /overlays/pi3-act-led.dtbo  SIZE: 569
14:52:49.472 ->   FILE: /overlays/pi3-disable-bt.dtbo  SIZE: 818
  FILE: /overlays/pi3-disable-wifi.dtbo  SIZE: 265
14:52:49.506 ->   FILE: /overlays/pi3-miniuart-bt.dtbo  SIZE: 1446
14:52:49.506 ->   FILE: /overlays/pibell.dtbo  SIZE: 2334
14:52:49.506 ->   FILE: /overlays/piscreen.dtbo  SIZE: 2713
14:52:49.506 ->   FILE: /overlays/piscreen2r.dtbo  SIZE: 2617
14:52:49.540 ->   FILE: /overlays/pisound.dtbo  SIZE: 2454
14:52:49.540 ->   FILE: /overlays/pitft22.dtbo  SIZE: 1544
14:52:49.540 ->   FILE: /overlays/pitft28-capacitive.dtbo  SIZE: 2385
14:52:49.540 ->   FILE: /overlays/pitft28-resistive.dtbo  SIZE: 2802
14:52:49.575 ->   FILE: /overlays/pitft35-resistive.dtbo  SIZE: 2802
14:52:49.575 ->   FILE: /overlays/pps-gpio.dtbo  SIZE: 1145
14:52:49.575 ->   FILE: /overlays/pwm-2chan.dtbo  SIZE: 1057
  FILE: /overlays/pwm-ir-tx.dtbo  SIZE: 1031
14:52:49.609 ->   FILE: /overlays/pwm.dtbo  SIZE: 946
14:52:49.609 ->   FILE: /overlays/qca7000.dtbo  SIZE: 1315
14:52:49.609 ->   FILE: /overlays/raspidac3.dtbo  SIZE: 1301
  FILE: /overlays/README  SIZE: 79565
14:52:49.644 ->   FILE: /overlays/rotary-encoder.dtbo  SIZE: 1922
14:52:49.644 ->   FILE: /overlays/rpi-backlight.dtbo  SIZE: 489
14:52:49.644 ->   FILE: /overlays/rpi-cirrus-wm5102.dtbo  SIZE: 3406
14:52:49.678 ->   FILE: /overlays/rpi-dac.dtbo  SIZE: 643
14:52:49.678 ->   FILE: /overlays/rpi-display.dtbo  SIZE: 2598
14:52:49.678 ->   FILE: /overlays/rpi-ft5406.dtbo  SIZE: 1018
  FILE: /overlays/rpi-proto.dtbo  SIZE: 771
14:52:49.712 ->   FILE: /overlays/rpi-sense.dtbo  SIZE: 893
14:52:49.712 ->   FILE: /overlays/rpi-tv.dtbo  SIZE: 499
  FILE: /overlays/rra-digidac1-wm8741-audio.dtbo  SIZE: 1298
14:52:49.746 ->   FILE: /overlays/sc16is750-i2c.dtbo  SIZE: 1174
14:52:49.746 ->   FILE: /overlays/sc16is752-i2c.dtbo  SIZE: 1344
14:52:49.746 ->   FILE: /overlays/sc16is752-spi1.dtbo  SIZE: 1875
14:52:49.781 ->   FILE: /overlays/sdhost.dtbo  SIZE: 846
14:52:49.781 ->   FILE: /overlays/sdio-1bit.dtbo  SIZE: 1729
14:52:49.781 ->   FILE: /overlays/sdio.dtbo  SIZE: 1797
  FILE: /overlays/sdtweak.dtbo  SIZE: 699
14:52:49.815 ->   FILE: /overlays/smi-dev.dtbo  SIZE: 376
14:52:49.815 ->   FILE: /overlays/smi-nand.dtbo  SIZE: 1508
14:52:49.849 ->   FILE: /overlays/smi.dtbo  SIZE: 981
14:52:49.849 ->   FILE: /overlays/spi-gpio35-39.dtbo  SIZE: 666
14:52:49.849 ->   FILE: /overlays/spi-rtc.dtbo  SIZE: 635
  FILE: /overlays/spi0-cs.dtbo  SIZE: 919
14:52:49.887 ->   FILE: /overlays/spi0-hw-cs.dtbo  SIZE: 492
14:52:49.887 ->   FILE: /overlays/spi1-1cs.dtbo  SIZE: 1547
  FILE: /overlays/spi1-2cs.dtbo  SIZE: 1920
14:52:49.917 ->   FILE: /overlays/spi1-3cs.dtbo  SIZE: 2293
14:52:49.917 ->   FILE: /overlays/spi2-1cs.dtbo  SIZE: 1547
14:52:49.951 ->   FILE: /overlays/spi2-2cs.dtbo  SIZE: 1920
14:52:49.951 ->   FILE: /overlays/spi2-3cs.dtbo  SIZE: 2293
14:52:49.951 ->   FILE: /overlays/superaudioboard.dtbo  SIZE: 1968
14:52:49.985 ->   FILE: /overlays/sx150x.dtbo  SIZE: 35594
14:52:49.985 ->   FILE: /overlays/tinylcd35.dtbo  SIZE: 4878
14:52:49.985 ->   FILE: /overlays/uart0.dtbo  SIZE: 928
14:52:50.019 ->   FILE: /overlays/uart1.dtbo  SIZE: 980
14:52:50.019 ->   FILE: /overlays/upstream-aux-interrupt.dtbo  SIZE: 715
  FILE: /overlays/upstream.dtbo  SIZE: 3215
14:52:50.053 ->   FILE: /overlays/vc4-fkms-v3d.dtbo  SIZE: 1412
14:52:50.053 ->   FILE: /overlays/vc4-kms-v3d.dtbo  SIZE: 2367
  FILE: /overlays/vga666.dtbo  SIZE: 758
14:52:50.088 ->   FILE: /overlays/w1-gpio-pullup.dtbo  SIZE: 1251
14:52:50.088 ->   FILE: /overlays/w1-gpio.dtbo  SIZE: 1116
  FILE: /overlays/wittypi.dtbo  SIZE: 1080
14:52:50.122 ->   FILE: /bcm2708-rpi-0-w.dtb  SIZE: 22264
14:52:50.122 ->   FILE: /bcm2708-rpi-b.dtb  SIZE: 21761
14:52:50.122 ->   FILE: /bcm2708-rpi-b-plus.dtb  SIZE: 22020
14:52:50.122 ->   FILE: /bcm2708-rpi-cm.dtb  SIZE: 21474
14:52:50.122 ->   FILE: /bcm2709-rpi-2-b.dtb  SIZE: 23044
14:52:50.122 ->   FILE: /bcm2710-rpi-3-b.dtb  SIZE: 24240
14:52:50.122 ->   FILE: /bcm2710-rpi-3-b-plus.dtb  SIZE: 24503
14:52:50.156 ->   FILE: /bcm2710-rpi-cm3.dtb  SIZE: 22952
14:52:50.156 ->   FILE: /bootcode.bin  SIZE: 52064
14:52:50.156 ->   FILE: /BUILD-DATA  SIZE: 303
14:52:50.156 ->   FILE: /INSTRUCTIONS-README.txt  SIZE: 2356
14:52:50.156 ->   FILE: /recovery.cmdline  SIZE: 85
14:52:50.156 ->   FILE: /recovery.elf  SIZE: 673444
14:52:50.156 ->   FILE: /recovery.img  SIZE: 2987384
14:52:50.156 ->   FILE: /recovery.rfs  SIZE: 28565504
14:52:50.156 ->   FILE: /RECOVERY_FILES_DO_NOT_EDIT  SIZE: 0
14:52:50.189 ->   FILE: /recovery7.img  SIZE: 3052536
14:52:50.189 ->   FILE: /test.txt  SIZE: 1048576
14:52:50.189 ->   FILE: /foo.txt  SIZE: 13
14:52:50.189 -> Writing file: /hello.txt
14:52:50.189 -> File written
14:52:50.189 -> Appending to file: /hello.txt
14:52:50.189 -> Message appended
14:52:50.189 -> Reading file: /hello.txt
14:52:50.189 -> Read from file: Hello World!
14:52:50.189 -> Deleting file: /foo.txt
File deleted
14:52:50.223 -> Renaming file /hello.txt to /foo.txt
14:52:50.223 -> File renamed
14:52:50.223 -> Reading file: /foo.txt
14:52:50.223 -> Read from file: Hello World!
1048576 bytes read for 710 ms
1048576 bytes written for 1785 ms

Sunday, July 12, 2015

Pre-SVFIG talk: 3 Computers (Surface, ZOTAC, Raspberry Pi w/ Weaved WebIOPi) on 1 screen

LED-RaspberryPi3
Starting out here: https://code.google.com/p/webiopi/wiki/Tutorial_Basis, I've already had to retype this line, because my Pi died, so once again, save often and prepare to reset when things go south. I also figured out how to use DopBox here: http://raspi.tv/2013/how-to-use-dropbox-with-raspberry-pi.
In [16]:
import webiopi
import datetime
from IPython.core.display import HTML

GPIO = webiopi.GPIO
Unlike the sample code, I have a dual 7 segment LED display from the OSEPP™ 101 Arduino Basics Starter Kit @ http://osepp.com/products/kits/101-arduino-basic-starter-kit/. So, there's going to be 16 pins to describe and wire up. I have a picture of how I wired it up to the Pi, so let's see if that works here:

or see https://dl.dropboxusercontent.com/u/49100658/LED-RaspberryPi.png.
Had to split this cell, because the Download as PDF via LaTeX couldn't wrap the page overflow.
The "BCM numbering" reference, mentioned above, was a new reference to me, so I had to look it up here: http://raspberrypi.stackexchange.com/questions/12966/what-is-the-difference-between-board-and-bcm-for-gpio-pin-numbering. I guess that confirms that I have Raspberry Pi 1 model B revision 2.
Note that, at the moment, the Right LED is mostly not working, due to my poor soldering skills, but the Left one appears to be working fine. Maybe, since solder appears to "age", getting better or worse over time. Need to go to a GPIO expander, like https://www.sparkfun.com/products/8130 or https://learn.adafruit.com/mcp230xx-gpio-expander-on-the-raspberry-pi/overview since that chip is supported by https://code.google.com/p/webiopi/wiki/DIGITAL. I'm pretty sure that I still need a couple of Model 4116R-1-RC (8 Isolated Resistors) dips. The only question now is when I should switch.
In [2]:
# Left LED GPIO pin using BCM numbering
LeftPin = [2,3,4,7,8,9,10,11]
def Left (n):
    return LeftPin[n]
# GEN pin using "2nd func" @ https://en.wikipedia.org/wiki/Raspberry_Pi
Gen  = [17,18,27,22,23,24,25]
# Right LED using GEN pin numbering
def Right (n):
    return Gen[n]
# There are no more pins for the Right DP LED, so it's "extra"
Now, I need to define numbers as arrays of 7 "segments".
In [3]:
# Order a,b,c,d,e,f,g
Num0 = [1,1,1,1,1,1,0]
Num1 = [1,1,0,0,0,0,0]
Num2 = [1,1,0,1,1,0,1]
Num3 = [1,1,1,1,0,0,1]
Num4 = [0,1,1,0,0,1,1]
Num5 = [1,0,1,1,0,1,1]
Num6 = [1,0,1,1,1,1,1]
Num7 = [1,1,1,0,0,0,0]
Num8 = [1,1,1,1,1,1,1]
Num9 = [1,1,1,0,0,1,1]

Nums = [Num0,Num1,Num2,Num3,Num4,Num5,Num6,Num7,Num8,Num9]
Getting back to the Tutorial, we have to setup the LED's GPIOs. I'll use the left DP as the LIGHT and just turn it on here. I've started to add the initialization of all the other GPIOs, but I'm not running this update yet.
In [4]:
# setup function is automatically called at WebIOPi startup
def setup():
    # set the GPIO used by the 2 7 segment LEDS to output
    for x in LeftPin:
        GPIO.setFunction(Left(x), GPIO.OUT)
    for x in Gen:
        GPIO.setFunction(Left(x), GPIO.OUT)

    # retrieve current datetime
    now = datetime.datetime.now()

    # test the pin by turning it on
    GPIO.digitalWrite(Left(7), GPIO.HIGH)
In the loop function, again, I will start with minimal changes.
In [5]:
# loop function is repeatedly called by WebIOPi 
def loop():
    # retrieve current datetime
    now = datetime.datetime.now()

    # toggle light ON all days at the correct time
    #if ((now.hour == HOUR_ON) and (now.minute == 0) and (now.second == 0)):
    if ((now.second & 1) == 0):
        if (GPIO.digitalRead(Left(7)) == GPIO.LOW):
            GPIO.digitalWrite(Left(7), GPIO.HIGH)

    # toggle light OFF
    #if ((now.hour == HOUR_OFF) and (now.minute == 0) and (now.second == 0)):
    if ((now.second & 1) == 1):
        if (GPIO.digitalRead(Left(7)) == GPIO.HIGH):
            GPIO.digitalWrite(Left(7), GPIO.LOW)

    # gives CPU some time before looping again
    webiopi.sleep(1)
Finally, we need to "destroy" the device, which just seems wrong, but here we go.
In [6]:
# destroy function is called at WebIOPi shutdown
def destroy():
    GPIO.digitalWrite(Left(7), GPIO.LOW)
By following the rest of the tutorial, I was able to get the left DP LED blinking, reliably until I had to just reset it and it appears that it did crash, or something...
I'm making these notes on the PC side, cause ipython is a little easier to use in Windows. However, due to the DropBox backup I'm using, this file appears to be write protected, so I had to rename it. Not a good solution yet.