SLAAEJ0 November 2023 AM625 , MSPM0L1306
Follow the setups provided on AM62x Starter Kit EVM Quick Start Guide.
Processor SDK Linux for AM62x Version 9.0 was used in the experiment below.
Setup the SPI driver in Linux by modifying the kernel device tree using the following steps:
Find the k3-am625-sk.dts device tree file on the path <psdk-installation-path>/board-support/ti-linux-kernel/arch/arm64/boot/dts/ti
Modify the file as follows:
Inside &main_pmx0{...} add:
main_spi0_pins_default: main-spi0-pins-default {
pinctrl-single,pins = <
AM62X_IOPAD(0x01bc, PIN_OUTPUT, 0) /* (A14) SPI0_CLK */
AM62X_IOPAD(0x01c0, PIN_INPUT, 0) /* (B13) SPI0_D0 */
AM62X_IOPAD(0x01c4, PIN_OUTPUT, 0) /* (B14) SPI0_D1 */
AM62X_IOPAD(0x01b4, PIN_OUTPUT, 0) /* (A13) SPI0_CS0 */
>;
};
At the end of the file, add:
&main_spi0 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&main_spi0_pins_default>;
spidev@0 {
spi-max-frequency = <16000000>;
reg = <0>;
compatible = "rohm,dh2228fv";
};
};
Recompile the kernel using the steps given on User Guide - Processor SDK AM62x. While following steps on this page, customize the kernel by using menuconfig as per the Kernel Configuration section provided on SPI Kernel Driver. For more details, see the steps below.
HOST$ cd <psdk-installaion-path>/board-support/ti-linux-kernel/
HOST$ make defconfig ti_arm64_prone.config
HOST$ make ARCH=arm64 menuconfig
Device Drivers --->
[*] SPI support
<*> User mode SPI device driver support
#Save these changes to the .config file
HOST$ make Image dtbs modules
HOST$ sudo cp ./arch/arm64/boot/Image /media/<USER>/root/boot/
HOST$ sudo cp ./arch/arm64/boot/dts/ti/k3-am625-sk.dtb /media/root/boot/dtb/ti
HOST$ sudo -E env “PATH=$PATH” INSTALL_MOD_PATH=/media/<USER>/root make modules_install
HOST$ sync; sync
Copy the target C file to the SDK path and compile the C project file using any method given on Compiling Example Hello World Program. Using either method, you should have an executable file loaded into the SD card in the end. For more details, see the steps below.
HOST$ cd <Beyond-SDK-installation-path>/Beyond-SDK/am62x/MSPM0-ADC-RTC-Attach/MSPM0-ADC-Attach-SPI/<x_Byte_x_Channel_SPI>/Controller/AM62x-A53_Core_MAIN_Domain/
HOST$ cp <target-filename>.c <psdk-installation-path>/linux-devkit/
HOST$ cd <psdk-installation-path>/linux-devkit/
HOST$ source environment-setup
HOST$ ${CC} <target-filename>.c -o <output-filename>
HOST$ sudo cp <output-filename> /media/<USER>/root/home/root
HOST$ exit
Insert the SD card back into SK-AM62x and reboot the device.