#include <iostream>
#include <errno.h>
#include <wiringPiSPI.h>
#include <unistd.h>
// channel is the wiringPi name for the chip select (or chip enable) pin.
// Set this to 0 or 1, depending on how it's connected.
//static const int CHANNEL = 1;
static const int CHANNEL = 0;
int main()
{
int fd, result;
unsigned char buffer[100];
std::cout << "Initializing" << std::endl ;
// Configure the interface.
// CHANNEL insicates chip select,
// 500000 indicates bus speed.
fd = wiringPiSPISetup(CHANNEL, 500000);
std::cout << "Init result: " << fd << std::endl;
while(true)
{
buffer[0] = 0x55;
wiringPiSPIDataRW(CHANNEL, buffer, 1);
sleep(5);
}
}
By executing this program we get the message:
Unable to open SPI device: No such file or directory
We tried to load spi:
khadas@Khadas:/boot$ sudo gpio load spi
[sudo] password for khadas:
gpio: Unable to load/unload modules as this Pi has the device tree enabled.
You need to run the raspi-config program (as root) and select the
modules (SPI or I2C) that you wish to load/unload there and reboot.
sudo ls -l /dev/spi*
ls: cannot access ‘/dev/spi*’: No such file or directory
Is it possible to enable SPI without raspi-config?
Dear Frank
I have try to rebuild by your commant that is editing the vim3_linux.dts.
and I have sucesse rebuilding in the vim3_linux.dts file by edit spicc1 changed.
But I don’t find spi device at the /dev directory.
Please What I need to do additionally to add SPICC1 device to the / dev directory
Then , Copy fenix/linux/arch/arm64/boot/Image to you board and replace /boot/zImage,
copy fenix/linux/arch/arm64/boot/dts/amlogic/kvim3_linux.dtb to you board /boot/dtb.
Final,run $sync && sudo reboot in you board .
You should check the file generate time if update before you copy it .
It was confirmed that the kvim3_linux.dtb file and Image are newly created.
I copied it to the / boot directory and & sync && sudo reboot also executed normally.
I still can’t find spicc1 in / dev.
Let me know what I don’t know
Hei,
It’s very interesting to follow this discussion about SPI here.
Until now we solved this problem for our self, our Project.
We changed for now from Ubuntu to Android 9, because
the problems with HDMI and TS050 Display is until now
in Khadas Queue! we’re waiting for good messages.
But Now, we have the problems with Android…!!
We’re still waiting for a message from Khadas specialist @Terry
it’s not so easy to communicate with him, him’s response time is
average 8 days!
@numbqq 's patch is result
It’s so sorry, it is not work fine
but still i can’t spidev1.0 device
First step
$ git clone --depth 1 https://github.com/khadas/fenix
next setp
$ source env/setenv.sh
next step
$make
after building and then i have edit pwm_ef & spicc1 part in the file “linux/arch/arm64/boot/dts/amlogic/kvim3_linux.dts”
next setp
i have run :~/code/fenix/linux$ git diff arch/arm64/boot/dts/amlogic/kvim3_linux.dts
May I know what are your configurations for source env/setenv.sh .
Thanks you very much
Now I got stuck at that NO any dtb files generated in linux/arch/arm64/boot/dts after I succeeded to run make ARCH=arm64 kvims_defconfig .
I just want to follow this Building Kernels Manually to manually build kernel. Then I could use those updated dtb files to make bootimage
I am using khadas-vims-4.9.y branch and git log shown as below:
This is my configuration and I am not sure if I do make sense:
amo@ubuntu:~/workspace/vim3/fenix$ source env/setenv.sh
Choose Khadas board:
1. Edge
2. VIM1
3. VIM2
4. VIM3
5. VIM3L
Which board would you like? [2] 4
Choose uboot version:
1. uboot-2015.01
2. uboot-mainline
Which uboot version would you like? [1] 1
Choose linux version:
1. linux-4.9
Which linux version would you like? [1] 1
Choose distribution:
1. Ubuntu
2. Debian
Which distribution would you like? [1] 1
Choose Ubuntu release:
1. bionic
2. focal
Which Ubuntu release would you like? [1] 1
Choose Ubuntu type:
1. server
2. minimal
3. xfce
4. lxde
5. gnome
Which Ubuntu type would you like? [1] 2
Set architecture to 'arm64' by default.
Choose install type:
1. EMMC
2. SD-USB
Which install type would you like? [1] 1
===========================================
#VERSION: 1.0.1
#KHADAS_BOARD=VIM3
#VENDOR=Amlogic
#CHIP=A311D
#LINUX=4.9
#UBOOT=2015.01
#DISTRIBUTION=Ubuntu
#DISTRIB_RELEASE=bionic
#DISTRIB_TYPE=minimal
#DISTRIB_ARCH=arm64
#INSTALL_TYPE=EMMC
===========================================
Environment setup done.
Type 'make' to build.
Then I got error when I run make kernel && make debs && make and log shown below:
amo@ubuntu:~/workspace/vim3/fenix$ make kernel && make debs && make
Info: Build host: bionic
Info: Installing build dependencies
Info: Requires root privileges, please enter your passowrd!
[sudo] password for amo:
Hit:1 http://ppa.launchpad.net/webupd8team/atom/ubuntu bionic InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
gcc-arm-linux-gnueabihf : Depends: gcc-7-arm-linux-gnueabihf (>= 7.3.0-12~)
libpython2.7-dev : Depends: libpython2.7-stdlib (= 2.7.15~rc1-1) but 2.7.17-1~18.04ubuntu1.2 is to be installed
Depends: libpython2.7 (= 2.7.15~rc1-1) but 2.7.17-1~18.04ubuntu1.2 is to be installed
Depends: libexpat1-dev but it is not going to be installed
systemd-container : Depends: systemd (= 237-3ubuntu10)
uuid-dev : Depends: libuuid1 (= 2.31.1-0.4ubuntu3) but 2.31.1-0.4ubuntu3.7 is to be installed
E: Unable to correct problems, you have held broken packages.
Makefile:25: recipe for target 'kernel' failed
make: *** [kernel] Error 100
#### failed to build some targets (7 seconds) ####
@ChiaHungMou You host ubuntu is 18.04 , So you can’t build a 20.04 image . You can try to build in docker . About how to build in docker , you can follow README in fenix
Thank you for your dedicated support.
Yes I spent whole night and build up a whole new ubuntu 20.04 environment VM.
And Fenix works well on my new ubuntu 20.04 environment VM indeed.
However I just met some make error which did show on my past ubuntu 18.04 VM.
I am making sure if it’s caused by repo sync uncompleted so I just rm -rf whole repo and running repo sync now.