# Core3566
## Install Gentoo
- Connect Core3566 to computer in maskrom mode with USB.
- Connect serial cable to GPIO header pins 8 and 10 and listen using serial terminal emulator like `picocom -b 1500000 -e p /dev/ttyUSB0`
- `Docker` with privileges is needed. Run below commands in terminal.
```bash
mkdir -p ~/workspace
cd ~/workspace
curl -LO https://raw.githubusercontent.com/Necktwi/core3566/refs/heads/master/core3566Gentoo.sh
chmod +x core3566Gentoo.sh
./core3566Gentoo.sh
```
- This should build and flash Gentoo to Core3566 to give a login prompt in `picocom`.
- Running `core3566Gentoo.sh` again, may b to install Gentoo on another Core3566 or previous run failed, it won't do redundant work like downloading and building sources, it uses already built binaries.
- To start fresh, run `./core3566Gentoo.sh clean`.
### Overlays
- To disable `HDMI` and `USB`, may b to conserve power, remove `/core3566-waveshare-cm4-io-base-b-usb.dtbo /core3566-waveshare-cm4-io-base-b-hdmi.dtbo` from `FDTOVERLAYS` in `/boot/extlinux/extlinux.conf`
- To enable `CMOS RTC` add `/core3566-waveshare-cm4-io-base-b-rtc.dtbo` to overlays and add `blacklist rtc_rk808` to `/etc/modprobe.d/blacklist-rtc-rk808.conf`
- With CMOS battery installed, time will be persisted after 2 reboots.
- To control fan with header 4, use `/core3566-waveshare-cm4-io-base-b-fan.dtbo`
## Making SD card out of stock images
1. If SDK already installed go to 2 else download LUCKFOX_LINUX419_SDK from [here](https://drive.google.com/drive/folders/1HCNYaVqQMv0vGc4630fmHkq2Eldi9Y2z)
as ~/Dowloads/luckfox-sdk.tar.gz
```
mkdir -p ~/workspace/luckfox && cd ~/workspace/luckfox
tar xvf ~/Downloads/luckfox-sdk.tar.gz
mkdir -p .pyvenv/bin
ln -s /usr/bin/python2 .pyvenv/bin/python
export PATH=".pyvenv/bin:$PATH"
.repo/repo/repo sync -l
```
2. Build the kernel
```
export CROSS_COMPILE="$(pwd)/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-"
cd kernel
make ARCH=arm64 CC="${CROSS_COMPILE}gcc" -j`nproc` luckfox_core3566_linux_defconfig
make ARCH=arm64 CC="${CROSS_COMPILE}gcc" -j`nproc` rockchip/core3566-hdmi-lp4x-v1-linux.dtb Image
```
3. Download one of the OS images from [here](https://drive.google.com/drive/folders/1ac_wZOGWZGYym02FX6t44EKQeRXdm3OW) as ~/Downloads/core3566.img
```
cd ~/workspace/luckfox/tools/linux/Linux_Pack_Firmware/rockdev/
ln -s ~/Downloads/core3566.img ./update.img
./unpack.sh #gives ./output/Image/ with rootfs image
```
4. Make sdcard with a 64MB fat32 partiton and a ext4 partition with remaining space. format them and assign labels bootfs and rootfs.
5. Mount `rootfs` on `/mnt/sd/` and `bootfs` on `/mnt/sd/boot`
6. Prepare SD card
```
sudo mkdir /mnt/img
sudo mount ~/workspace/luckfox/tools/linux/Linux_Pack_Firmware/rockdev/output/Image/rootfs.img /mnt/img
sudo mkdir /mnt/img/oem
sudo mount ~/workspace/luckfox/tools/linux/Linux_Pack_Firmware/rockdev/output/Image/oem.img /mnt/img/oem
# comment out oem and userdata in fstab
sudo rsync -avpPh /mnt/img/ /mnt/sd
sudo cp ~/workspace/luckfox/kernel/arch/arm64/boot/Image /mnt/sd/boot/
sudo cp ~/workspace/luckfox/kernel/arch/arm64/boot/dts/rockchip/core3566-hdmi-lp4x-v1-linux.dtb /mnt/sd/boot/
sudo mkdir /mnt/sd/boot/extlinux/
sudo tee /mnt/sd/boot/extlinux/extlinux.conf <^|--|:*
+-77|77 |KEY_M_1
+--1|GND 3.3V|2-3.3V--
+--3|GND 3.3V|2-3.3V--
|--5|PETn3 3.3V|4-3.3V--
|--7|PETp3 NC|6-
+--9|GND NC|8-
| 11|PERn3 LED1#|10-LED1--
| 13|PERp3 3.3V|12-3.3V--
+-15|GND 3.3V|14-3.3V--
|-17|PETn2 3.3V|16-3.3V--
|-19|PETp2 3.3V|18-3.3V--
+-21|GND NC|20--
|-23|PERn2 NC|22--
|-25|PERp2 NC|24--
+-27|GND NC|26--
|-29|PETn1 NC|28--
|-31|PETp1 NC|30
+-33|GND NC|32
|-35|PERn1 NC|34
|-37|PERp1 NC|36
+-39|GND NC|38
PCIE_RX_N-|-41|PETn0 SMCLK|40
PCIE_RX_P-|-43|PETp0 SNDAT|42
| 45|GND ALERT|44
PCIE_TX_N-|-47|PERn0 NC|46
PCIE_TX_N-|-49|PERp0 NC|48
+-51|GND PREST#|50-PCIEnRST--
PCIE_CLK_N-|-53|REFCLK CLKREQ#|52
PCIE_CLK_N-|-55|REFCLK PEWAKE#|54
| 57|GND NC|56
| | NC|58
| | |
| | |
| | |
| 67|NC |
+-69|PEDET SUSCLK|68-3.3V--
+-71|GND 3.3V|70-3.3V--
+-73|GND 3.3V|72-3.3V--
+-75|GND 3.3V|74
*:|--+-76|66 |
```
## 52Pi New Ice Tower Cooler EP-0107
- 3pin; black: gnd, red: 12/5v, blue: pwm control
- no tach
## OV5647
### Working Configuration (from RPi3B)
The OV5647 camera module works in **MIPI CSI-2 mode** (not DVP). Key findings from RPi3B analysis:
**Sensor Properties:**
```
compatible = "ovti,ov5647"
reg = <0x36>
```
**Clock:**
```
clock-frequency = <25000000> (25MHz, fixed-clock)
```
**CSI Endpoint (MIPI CSI-2 mode):**
```
data-lanes = <1 2> (2 lanes)
clock-lanes = <0> (clock on lane 0)
clock-noncontinuous
link-frequencies = /bits/ 64 <297000000> (297MHz)
```
**Power Supplies (3 required):**
| Supply | Description | Typical Voltage |
|--------|-------------|-----------------|
| avdd-supply | Analog | 2.8V |
| dovdd-supply | Digital I/O | 1.8V |
| dvdd-supply | Digital Core | 1.2V |
**Regulator Settings:**
```
startup-delay-us = <20000> (20ms delay after enable)
enable-active-high
```
**I2C Bus:** i2c0mux/i2c@1 (camera I2C bus via mux)
**CSI:** csi@7e801000 (unicam)
- `rpicam-jpeg -o test.jpg --nopreview` - **WORKS**
- `vcgencmd get_camera` shows detected
- I2C address 0x36 responds when driver loaded
- Raspbian ov5647 overlay: `arch/arm/boot/dts/overlays/ov5647-overlay.dts`
- Raspbian ov5647 dtsi: `arch/arm/boot/dts/overlays/ov5647.dtsi`
### Core3566 key findings
- `i2cdetect -y 1` on core shows UU at 0x36
- /mnt/ventoy/workspace/linux-v7.0-rc7-core3566-ov5647/arch/arm64/boot/dts/rockchip/core3566-waveshare-cm4-io-base-b-ov5647.dtso is cross compiled on a container on the computer named slick; `ssh slick`
-
### References
--
HalfBloodPrince