Jump to content

Nick

Members
  • Posts

    140
  • Joined

  • Last visited

Everything posted by Nick

  1. Here is my SPI code #include "system.h" #include "spi.h" #include "debug.h" #include <stdint.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <getopt.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/types.h> #include <linux/spi/spidev.h> static const char *device = "/dev/spidev32766.0"; static uint8_t mode; static uint8_t bits = 8; static uint32_t speed = 500000; static uint16_t delay; static unsigned char rxByte; int fd; static void pabort(const char *s) { perror(s); abort(); } void spiInit(void) { unsigned int ret; printf("SpiInit()..."); fd = open(device, O_RDWR); if (fd < 0) { printf("can't open device: %s\r\n", device); abort(); } // mode |= SPI_LOOP; //mode |= SPI_CPHA; //mode |= SPI_CPOL; //mode |= SPI_LSB_FIRST; // mode |= SPI_CS_HIGH; // mode |= SPI_3WIRE; //mode |= SPI_NO_CS; // mode |= SPI_READY; /* * spi mode */ ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); if (ret == -1) pabort("can't set spi mode"); ret = ioctl(fd, SPI_IOC_RD_MODE, &mode); if (ret == -1) pabort("can't get spi mode"); /* * bits per word */ ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); if (ret == -1) pabort("can't set bits per word"); ret = ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits); if (ret == -1) pabort("can't get bits per word"); /* * max speed hz */ ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); if (ret == -1) pabort("can't set max speed hz"); ret = ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed); if (ret == -1) pabort("can't get max speed hz"); printf("Done.\r\n"); } void spiTxByte(unsigned char byte) { unsigned int ret; struct spi_ioc_transfer tr = { .tx_buf = (unsigned long)&byte, .rx_buf = (unsigned long)&rxByte, .len = 1, .delay_usecs = delay, .speed_hz = speed, .bits_per_word = bits, }; ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); // printf("spi: by: %#x, rxB: %#x\r\n",byte, rxByte); if (ret < 1) pabort("can't send spi message"); } unsigned char spiRxByte(void) { spiTxByte(0x00); return rxByte; }
  2. Looking at the signals on a scope, the CLK pin is awful. I've tried increasing the drive strength to 40mA in the DTB file to no avail. The MOSI line looks fine on the scope, but the CLK line looks more like a sinewave that a square wave. If I override the CLK pin using the /sys/class/gpio then the line goes high, so I am confident that there are no electrical shorts on the board.
  3. True, I probably should have mentioned that the FEX file is compiled first for completeness :-)
  4. Brilliant, that's good to know, at least I can just concentrate on checking the settings in mainline without having to worry about the FEX file as well. Just out of interest, if I'm using mainline, is the FEX file used at all, for example by UBOOT or the SoC's internal bootloader? In other words, if were to delete the fex file from the SD card whilst using mainline would it still work? Getting back to the SPI... I've checked and re-checked my DTB file (including decompiling the file on the device), and SPI appears to be enable, it appears to be using the correct pins as per the schematic and spidev32766.0 appears in /dev My code (which worked with the legacy kernel) is very similar to the code found here: https://linux-sunxi.org/SPIdev there are no apparent erros when the code runs, but nothing is output on any of the physical SPI pins.
  5. Hi Zador, Once again you come to my rescue, thank you :-) I have the GPIO working now, just trying to debug the SPI port. I have a device but no pins toggling at the moment. Just out of interest, is the FEX file used at all by mainline now, or does it just use DTB?
  6. Could you not use a normal GPIO pin for the turnaround? That is how I deal with RS485 on 8bit Micros etc. In theory, the GPIO pins can be accessed via the /sys/class/gpio file system, however I'm currently having trouble with that on a Banana Pi M1+, so you might want to keep an eye on my other thread. Nick
  7. I'm currently playing with a Banana Pi M1 + and don't seem to be able to get the GPIO to work. I *think* that I have correctly mapped the IO pins that I am using through the schematic and fex file to find the corrisponding GPIO number for debian. When playing around in /sys/class/gpio I am able to export the GPIO pin that I'm looking for and change it's properties, direction, value etc. However these changes don't seem to appear on the physical IO pins. I noticed that some of the pins that I'm using are shared by UART 2, so I have disabled that in the FEX file but still no luck. I have a feeling that this is probably going to be DTB related, however I'm a little confused by the fact that Debian allows me to export them.
  8. Is that the internal PHY now working under the mainline kernel or are you using a USB dongle?
  9. Oh wonderful, I hadn't noticed that bit. When you mentioned lib.config earlier, I thought you were referring to the lib/config directory. I couldn't see how that would work. You guys seem to have thought of everything :-)
  10. Can the variables in configuration.sh be overwritten from the command line then? Looking at the way everything is put together, source configuration.sh seems to come after the variables are parsed and therefore overwrite anything that is added to the command line. I haven't actually tried it yet though, so it may be that I have just mis-read the code.
  11. I hope you guys don't mind, I have created a patch to ignore PAKETKI from a command line option. The patch does 2 things: 1) corrects a spelling mistake in debootstrap.sh 2) checks to see if the variable NOPAKETKI == yes. If it is then it sets PAKETKI to "" just before install_packet is called. This is the first time I have prepared a patch for public consumption so please let me know if I have done anything wrong. On another note, if you guys don't mind I would like to look at the idea of moving board configs into separate files, but I'll create a separate thread for that if you don't mind me having a go. diff --git a/debootstrap.sh b/debootstrap.sh index fcc331d..8f09152 100644 --- a/debootstrap.sh +++ b/debootstrap.sh @@ -48,7 +48,7 @@ fi LOOP=$(losetup -f) if [[ "$LOOP" != "/dev/loop0" && "$LOOP" != "/dev/loop1" ]]; then -display_alert "You run out of loop devices" "pleese reboot" "error" +display_alert "You run out of loop devices" "please reboot" "error" exit fi @@ -181,6 +181,10 @@ LC_ALL=C LANGUAGE=C LANG=C chroot $DEST/cache/sdcard /bin/bash -c "locale-gen $D LC_ALL=C LANGUAGE=C LANG=C chroot $DEST/cache/sdcard /bin/bash -c "export CHARMAP=$CONSOLE_CHAR FONTFACE=8x16 LANG=$DEST_LANG LANGUAGE=$DEST_LANG DEBIAN_FRONTEND=noninteractive" LC_ALL=C LANGUAGE=C LANG=C chroot $DEST/cache/sdcard /bin/bash -c "update-locale LANG=$DEST_LANG LANGUAGE=$DEST_LANG LC_MESSAGES=POSIX" +if [[ $NOPAKETKI == yes ]]; then + PAKETKI="" + display_alert "Ignoring" "PAKETKI" "O.K." +fi install_packet "$PAKETKI" "Installing Armbian on the top of $DISTRIBUTION $RELEASE base system ..." @@ -211,4 +215,4 @@ mount -t proc chproc $DEST/cache/sdcard/proc mount -t sysfs chsys $DEST/cache/sdcard/sys mount -t devtmpfs chdev $DEST/cache/sdcard/dev || mount --bind /dev $DEST/cache/sdcard/dev mount -t devpts chpts $DEST/cache/sdcard/dev/pts -} \ No newline at end of file +}
  12. I've have just looked at the last SD card that I burned last night and everything looks to be in place now. I was having trouble with an SD card so I switched to a new one. I'm guessing the old card was not being written properly for some reason. Sorry about that, all appears to be good now :-) Thanks for the hint regarding /tmp not being copied into the image, I didn't know that. It makes sense for it not to be copied, but it might be worth adding a note to the comment at the top of the script.
  13. Subtitle: Or I've screwed (Which is more than likely ;-) I'm trying to add some custom apt sources via customize_image.sh. They appear to be being added, but they are then deleted again. #!/bin/bash # arguments: $RELEASE $FAMILY $BOARD $BUILD_DESKTOP # # This is the image customization script # # NOTE: It is copied to /tmp directory inside the image # and executed there inside chroot environment # so don't reference any files that are not already installed RELEASE=$1 FAMILY=$2 BOARD=$3 BUILD_DESKTOP=$4 # add TV Headend echo "deb http://dl.bintray.com/tvheadend/deb jessie release" >> /etc/apt/sources.list.d/nimo.list wget apt.nimo.co.uk/conf/tvheadend.key cat ./tvheadend.key |apt-key add - #rm ./tvheadend.key #Add NIMO GPG key echo "deb http://apt.nimo.co.uk/'>http://apt.nimo.co.uk/ nimo main" >> /etc/apt/sources.list.d/nimo.list wget apt.nimo.co.uk/conf/nimo.gpg.key cat ./nimo.gpg.key | apt-key add - #rm ./nimo.gpg.key #Add nimobridge setup program apt-get -y update apt-get -y install nimoapsetup nimocoresetup case $RELEASE in wheezy) # your code here ;; jessie) # your code here ;; trusty) # your code here ;; esac When apt-get -y update is run by the build process it appears to find my repository and is happy. Get:1 http://apt.nimo.co.uk nimo InRelease [1,474 B] Hit http://security.debian.org jessie/updates InRelease Get:2 http://apt.nimo.co.uk nimo/main armhf Packages [937 B] Get:3 http://httpredir.debian.org jessie-updates InRelease [136 kB] Ign http://httpredir.debian.org jessie InRelease Hit http://security.debian.org jessie/updates/main Sources Hit http://security.debian.org jessie/updates/contrib Sources Hit http://security.debian.org jessie/updates/non-free Sources Hit http://httpredir.debian.org jessie Release.gpg Hit http://security.debian.org jessie/updates/main armhf Packages Hit http://security.debian.org jessie/updates/contrib armhf Packages Hit http://httpredir.debian.org jessie Release Hit http://security.debian.org jessie/updates/non-free armhf Packages Ign http://apt.nimo.co.uk nimo/main Translation-en_GB Hit http://security.debian.org jessie/updates/contrib Translation-en Ign http://apt.nimo.co.uk nimo/main Translation-en Hit http://security.debian.org jessie/updates/main Translation-en Hit http://security.debian.org jessie/updates/non-free Translation-en Get:4 http://httpredir.debian.org jessie-updates/main Sources [2,296 B] Get:5 http://httpredir.debian.org jessie-updates/main armhf Packages/DiffIndex [367 B] Get:6 http://httpredir.debian.org jessie-updates/contrib Sources [32 B] Get:7 http://httpredir.debian.org jessie-updates/contrib armhf Packages [32 B] Get:8 http://httpredir.debian.org jessie-updates/non-free Sources [32 B] Get:9 http://httpredir.debian.org jessie-updates/non-free armhf Packages [32 B] Get:10 http://httpredir.debian.org jessie-updates/contrib Translation-en [14 B] Get:11 http://httpredir.debian.org jessie-updates/main Translation-en [2,506 B] Hit http://httpredir.debian.org jessie/main Sources Hit http://httpredir.debian.org jessie/contrib Sources Hit http://httpredir.debian.org jessie/non-free Sources Hit http://httpredir.debian.org jessie/main armhf Packages Get:12 http://httpredir.debian.org jessie-updates/non-free Translation-en [14 B] Hit http://httpredir.debian.org jessie/contrib armhf Packages Hit http://httpredir.debian.org jessie/non-free armhf Packages Hit http://httpredir.debian.org jessie/contrib Translation-en Hit http://httpredir.debian.org jessie/main Translation-en Hit http://httpredir.debian.org jessie/non-free Translation-en Which leads me to believe that nimo.list is being created and that the keys are being added correctly. However when I copy the final .raw file to an SD card and look at it, /etc/apt/sources.list.d/nimo.list has gone as well as the two key files which as far as I understand it should be in /tmp This is my first attempt at using customize_image.sh so there may be other things going on which I haven't taken into account yet.
  14. Hi Zador Thanks for that, if you would like me to test it at any point let me know. As for the custom board idea, it's not a problem. I like your idea of including the configurations as separate files and would love to see something similar implemented in the future, however as I mentioned it's not something that is critical for me at the moment.
  15. I guess the downside of customize-image.sh is that everything has to be downloaded, installed and then most of the packages uninstalled again via cust...sh as you say, not optimal. That said it works. Having tried Zador's idea of commenting out PAKETI entirely, I do like that and it actually suits my application very well. So if there is any chance of having an option that ignores PAKETI entirely then that would be wonderful, as I can do everything else via customize-image.sh That looks like an interesting project and actually very close to one of the units in my project, you mention that it is outdated, by how much? Does it support the next kernel and the H3 SoC's by any chance? Perhaps merging it with Armbian is a way of bringing it up to date? I noticed that you used a custom case, I'm using this one http://uk.farnell.com/pro-power/g17081ubk/case-19-abs-1u-black/dp/1526723?ost=1526723&selectedCategoryId=I don't know if that helps you at all? The next question may require a topic of it's own, but I'll ask it here anyway for the moment: Is there any way of adding new boards to the build process without having them added to the main Armbian code? It's not a problem at the moment, however I'm hopefully going to be designing my own custom boards for these projects soon (I'm a Hardware engineer during the day) but my assumption is that if I were to add them into boards.sh then they would be overwritten when I next pull the build code from git?
  16. Well Armbian builds with PAKETI commented out which is good. the system boots and appears to run as expected. The MOTD fails as some of the required packages aren't present and I'm sure there will be other things that fail as well, but so far so good
  17. That's a interesting idea, I'm running a build at the moment but I'll try a build with PAKETI commented out later and see if / how much of the build process is broken. The combination of that and customize-image.sh may be exactly what I'm looking for. I agree entirely, which is why the use of customize-image is essential, for example I'm working on two projects at the moment one requires WiFi and the other doesn't, so even my initial thought of including the WiFi tools wouldn't be "minimal" enough for my other project. One potential advantage to developing the the idea of an absolute minimal PAKETI would be to allow for future expansion of the install desktop menu option. Instead of being a simple install desktop yes / no, it could include options for building a server, building an access point, building a NAS image etc.
  18. Would it be possible to add an option build parameter, something along the lines of BUILD_MINIMAL_DISTRO to the compile system? Allowing it as a command line option to compile.sh would be great as well. The purpose of the new option would be to use an alternative PAKETKI variable with only the packages absolutely required for running the system and configuring networking (ideally Ethernet and WiFI) without the bloat of bluez, stress etc. It would also be great if there was a call after install_external_applications to a user provided script that allows the user to install any additional packages that they require. There may be reasons not to do this and / or better ways of implementing equivalent functionality but any thoughts / comments would be great. Nick
  19. Hi Joe, How much are the mugs and do you have any idea of how much shipping to the UK would be? I love the blue handle, and would be more than happy to buy one as long as they aren't too expensive :-) Nick
  20. I wonder if that was BT's problem in the UK yesterday?? ;-) For those of you not in the UK, BT had a huge outage yesterday covering big areas of the country. http://www.theguardian.com/business/2016/feb/02/bt-broadband-phone-network-down-uk-areas-birmingham-london-sheffield BTW: Sorry for the off topic post :-)
  21. The card here: http://www.embeddedworks.net/wlan483.htmlis listed as a USB WiFi module so I doubt you will get very far by connecting it to the UART, especially if as your first post suggests you connect TXD -> Data - and RXD -> Data +. Why not use 3 of your 4 USB connectors for WIFI and Ethernet, then attach a USB hub to the 4th port for whatever else you want to plug in?
  22. I've been playing with a fresh 4.3.4 image that I've just compiled and had at least a small success... For the moment I've given up on patches etc. and just played with the files on the device. I have edited and recompiled boot.cmd to ensure that it is pointing to the m1-plus.dtb file (and confirmed with cat /proc/device-tree/model) Followed by adding your edits to the m1-plus.dtb file.I now finally have root@bananapipro:~# ls /dev/spi* /dev/spidev32766.0 Which although I haven't yet tested to see if pins are toggling is a great step forward. As a side note, where does the 32766 come from? I don't really care what the device is called, I just need to know that either it isn't going to change so that I can hard code it into my application, or find a reliable way of allowing my application to choose the correct device at runtime. Thank you ever so much for your help so far.
  23. Did you mean to try it on a fresh 4.5 or fresh 4.3.4 image? I've just tried 4.3.4 and that didn't work.
  24. Funnily enough, I just had the same thought, I was almost certain that I had recompiled it, but figured that I would try it anyway. Since recompiling the pi wont boot. U-Boot SPL 2016.01-armbian (Jan 30 2016 - 20:12:05) DRAM: 1024 MiB CPU: 912000000Hz, AXI/AHB/APB: 3/2/2 Trying to boot from MMC U-Boot 2016.01-armbian (Jan 30 2016 - 20:12:05 +0000) Allwinner Technology CPU: Allwinner A20 (SUN7I) I2C: ready DRAM: 1 GiB MMC: SUNXI SD/MMC: 0 *** Warning - bad CRC, using default environment Setting up a 720x576i composite-pal console (overscan 32x20) In: serial Out: vga Err: vga SCSI: SUNXI SCSI INIT SATA link 0 timeout. AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode flags: ncq stag pm led clo only pmp pio slum part ccc apst Net: eth0: ethernet@01c50000 starting USB... USB0: USB EHCI 1.00 USB1: USB OHCI 1.0 USB2: USB EHCI 1.00 USB3: USB OHCI 1.0 scanning bus 0 for devices... 1 USB Device(s) found scanning bus 2 for devices... 1 USB Device(s) found Hit any key to stop autoboot: 0 switch to partitions #0, OK mmc0 is current device Scanning mmc 0:1... Found U-Boot script /boot/boot.scr 2341 bytes read in 343 ms (5.9 KiB/s) ## Executing script at 43100000 0 bytes read in 262 ms (0 Bytes/s) 28020 bytes read in 1159 ms (23.4 KiB/s) 4775680 bytes read in 540 ms (8.4 MiB/s) Kernel image @ 0x46000000 [ 0x000000 - 0x48df00 ] ## Flattened Device Tree blob at 49000000 Booting using the fdt blob at 0x49000000 Using Device Tree in place at 49000000, end 49009d73 Starting kernel ... Uncompressing Linux... done, booting the kernel.
  25. You did, my apologies, I ended up getting side tracked by the other things that we were doing. root@bananapipro:~# cat /proc/device-tree/model LeMaker Banana Pro Which is interesting as I have boot.cmd pointing to sun7i-a20-bananapi-m1-plus.dtb root@bananapipro:~# cat /boot/boot.cmd # if you want to boot jessie with systemd: setenv bootargs init=/bin/systemd console=tty1 ... # remember to disable ramlog prior switching to systemd setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk0p1 rootwait rootfstype=ext4 cgroup-enable=memory swapaccount=1 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve sunxi_fb_mem_reserve=16 hdmi.audio=EDID:0 disp.screen0_output_mode=1920x1080p60 panic=10 consoleblank=0 enforcing=0 loglevel=1" #-------------------------------------------------------------------------------------------------------------------------------- # Boot loader script to boot with different boot methods for old and new kernel #-------------------------------------------------------------------------------------------------------------------------------- if ext4load mmc 0 0x00000000 /boot/.next || fatload mmc 0 0x00000000 .next || ext4load mmc 0 0x00000000 .next then # sunxi mainline kernel #-------------------------------------------------------------------------------------------------------------------------------- #ext4load mmc 0 0x49000000 /boot/dtb/${fdtfile} || fatload mmc 0 0x49000000 /dtb/${fdtfile} || ext4load mmc 0 0x49000000 /dtb/${fdtfile} ext4load mmc 0 0x49000000 /boot/dtb/sun7i-a20-bananapi-m1-plus.dtb || fatload mmc 0 0x49000000 /dtb/sun7i-a20-bananapi-m1-plus.dtb ext4load mmc 0 0x46000000 /boot/zImage || fatload mmc 0 0x46000000 zImage || ext4load mmc 0 0x46000000 zImage env set fdt_high ffffffff bootz 0x46000000 - 0x49000000 #-------------------------------------------------------------------------------------------------------------------------------- else # sunxi android kernel #-------------------------------------------------------------------------------------------------------------------------------- ext4load mmc 0 0x43000000 /boot/script.bin || fatload mmc 0 0x43000000 script.bin || ext4load mmc 0 0x43000000 script.bin ext4load mmc 0 0x48000000 /boot/zImage || fatload mmc 0 0x48000000 zImage || ext4load mmc 0 0x48000000 zImage bootz 0x48000000 #-------------------------------------------------------------------------------------------------------------------------------- fi # Recompile with: # mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr root@bananapipro:~#
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines