Skip to content

Commit

Permalink
Merge pull request #64 from YuzukiHD/dev
Browse files Browse the repository at this point in the history
spilcd add splash, clk add change cpu freq and fix pll, update longanpi 4b
  • Loading branch information
SamulKyull authored Apr 13, 2024
2 parents 43f18f0 + 97bc969 commit fbbd5fd
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 96 deletions.
5 changes: 5 additions & 0 deletions board/avaota-a1/extlinux_boot/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,14 @@ int main(void) {
pmu_axp2202_set_vol(&i2c_pmu, "dcdc3", 1160, 1);
pmu_axp2202_set_vol(&i2c_pmu, "dcdc4", 3300, 1);

pmu_axp2202_set_vol(&i2c_pmu, "bldo3", 1800, 1);
pmu_axp2202_set_vol(&i2c_pmu, "bldo1", 1800, 1);

pmu_axp2202_dump(&i2c_pmu);
pmu_axp1530_dump(&i2c_pmu);

sunxi_clk_set_cpu_pll(1224);

enable_sram_a3();

/* Initialize the DRAM and enable memory management unit (MMU). */
Expand Down
15 changes: 8 additions & 7 deletions board/avaota-a1/extlinux_boot/spi_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,19 +360,19 @@ const unsigned char ascii_1206[][12] = {
{0x16, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"~",94*/
};

void LCD_ShowChar(uint16_t x, uint16_t y, uint8_t num, uint16_t fc, uint16_t bc, uint8_t sizey) {
static void LCD_ShowChar(uint16_t x, uint16_t y, uint8_t num, uint16_t fc, uint16_t bc, uint8_t sizey) {
uint8_t temp, sizex, t, m = 0;
uint16_t i, TypefaceNum;//一个字符所占字节大小
uint16_t i, TypefaceNum;// Number of bytes for one character
uint16_t x0 = x;
sizex = sizey / 2;
TypefaceNum = (sizex / 8 + ((sizex % 8) ? 1 : 0)) * sizey;
num = num - ' '; //得到偏移后的值
LCD_Address_Set(x, y, x + sizex - 1, y + sizey - 1);//设置光标位置
num = num - ' '; // Get the offset value
LCD_Address_Set(x, y, x + sizex - 1, y + sizey - 1);// Set the cursor position
for (i = 0; i < TypefaceNum; i++) {
temp = ascii_1206[num][i];//调用6x12字体
temp = ascii_1206[num][i];// Call 6x12 font
for (t = 0; t < 8; t++) {

if (temp & (0x01 << t)) LCD_WR_DATA(fc);
if (temp & (0x01 << t))
LCD_WR_DATA(fc);
else
LCD_WR_DATA(bc);
m++;
Expand All @@ -384,6 +384,7 @@ void LCD_ShowChar(uint16_t x, uint16_t y, uint8_t num, uint16_t fc, uint16_t bc,
}
}


static void LCD_ShowString(uint16_t x, uint16_t y, const uint8_t *p, uint16_t fc, uint16_t bc, uint8_t sizey) {
printk(LOG_LEVEL_DEBUG, "LCD: Show String: \"%s\"\n", p);
while (*p != '\0') {
Expand Down
104 changes: 55 additions & 49 deletions board/longanpi-4b/extlinux_boot/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#include <sstdlib.h>
#include <string.h>

#include <cli.h>
#include <cli_shell.h>
#include <cli_termesc.h>

#include <sys-clk.h>
#include <sys-dram.h>
#include <sys-i2c.h>
Expand Down Expand Up @@ -53,8 +49,6 @@

#define CONFIG_SDMMC_SPEED_TEST_SIZE 1024// (unit: 512B sectors)

#define CONFIG_DEFAULT_BOOTDELAY 3

#define CONFIG_HEAP_BASE (0x50800000)
#define CONFIG_HEAP_SIZE (16 * 1024 * 1024)

Expand Down Expand Up @@ -107,6 +101,26 @@ typedef struct {
char extlinux_filename[FILENAME_MAX_LEN];
} image_info_t;

#define IH_COMP_NONE 0 /* No Compression Used */
#define IH_COMP_GZIP 1 /* gzip Compression Used */
#define IH_COMP_BZIP2 2 /* bzip2 Compression Used */
#define IH_MAGIC 0x56190527 /* mkimage magic for uinitrd */
#define IH_NMLEN 32 /* Image Name Length */
typedef struct image_header {
uint32_t ih_magic; /* Image Header Magic Number */
uint32_t ih_hcrc; /* Image Header CRC Checksum */
uint32_t ih_time; /* Image Creation Timestamp */
uint32_t ih_size; /* Image Data Size */
uint32_t ih_load; /* Data Load Address */
uint32_t ih_ep; /* Entry Point Address */
uint32_t ih_dcrc; /* Image Data CRC Checksum */
uint8_t ih_os; /* Operating System */
uint8_t ih_arch; /* CPU architecture */
uint8_t ih_type; /* Image Type */
uint8_t ih_comp; /* Compression Type */
uint8_t ih_name[IH_NMLEN]; /* Image Name */
} image_header_t;

image_info_t image;

#define CHUNK_SIZE 0x20000
Expand Down Expand Up @@ -449,7 +463,15 @@ static int load_extlinux(image_info_t *image, uint64_t dram_size) {
if (ramdisk_size > 0) {
uint64_t addr, size;

/* Check if using uinitrd */
image_header_t *ramdisk_header = (image_header_t *) image->ramdisk_dest;

if (ramdisk_header->ih_magic == IH_MAGIC) {
ramdisk_start += 0x40;
}

printk(LOG_LEVEL_DEBUG, "initrd_start = 0x%08x, initrd_end = 0x%08x\n", ramdisk_start, ramdisk_end);

int total = fdt_num_mem_rsv(image->of_dest);

printk(LOG_LEVEL_DEBUG, "Look for an existing entry %d\n", total);
Expand Down Expand Up @@ -482,6 +504,7 @@ static int load_extlinux(image_info_t *image, uint64_t dram_size) {
}
}

_set_bootargs:
len = 0;
/* Get bootargs string */
char *bootargs_str = (void *) fdt_getprop(image->of_dest, chosen_node, "bootargs", &len);
Expand Down Expand Up @@ -536,36 +559,6 @@ static int load_extlinux(image_info_t *image, uint64_t dram_size) {
return err;
}

msh_declare_command(boot);
msh_define_help(boot, "boot to linux", "Usage: boot\n");
int cmd_boot(int argc, const char **argv) {
atf_head_t *atf_head = (atf_head_t *) image.bl31_dest;

atf_head->dtb_base = (uint32_t) image.of_dest;
atf_head->nos_base = (uint32_t) image.kernel_dest;

/* Fill platform magic */
memcpy(atf_head->platform, CONFIG_PLATFORM_MAGIC, 8);

printk(LOG_LEVEL_INFO, "ATF: Kernel addr: 0x%08x\n", atf_head->nos_base);
printk(LOG_LEVEL_INFO, "ATF: Kernel DTB addr: 0x%08x\n", atf_head->dtb_base);

clean_syterkit_data();

jmp_to_arm64(CONFIG_BL31_LOAD_ADDR);

printk(LOG_LEVEL_INFO, "Back to SyterKit\n");

// if kernel boot not success, jump to fel.
jmp_to_fel();
return 0;
}

const msh_command_entry commands[] = {
msh_define_command(boot),
msh_command_end,
};

static int abortboot_single_key(int bootdelay) {
int abort = 0;
unsigned long ts;
Expand Down Expand Up @@ -659,7 +652,7 @@ int main(void) {
/* Initialize the SD host controller. */
if (sunxi_sdhci_init(&sdhci0) != 0) {
printk(LOG_LEVEL_ERROR, "SMHC: %s controller init failed\n", sdhci0.name);
goto _shell;
goto _fail;
} else {
printk(LOG_LEVEL_INFO, "SMHC: %s controller initialized\n", sdhci0.name);
}
Expand All @@ -670,34 +663,47 @@ int main(void) {
mdelay(30);
if (sdmmc_init(&card0, &sdhci0) != 0) {
printk(LOG_LEVEL_WARNING, "SMHC: init failed\n");
goto _shell;
goto _fail;
}
}

/* Load the DTB, kernel image, and configuration data from the SD card. */
if (load_sdcard(&image) != 0) {
printk(LOG_LEVEL_WARNING, "SMHC: loading failed\n");
goto _shell;
}
goto _fail;
}-

if (load_extlinux(&image, dram_size) != 0) {
printk(LOG_LEVEL_ERROR, "EXTLINUX: load extlinux failed\n");
goto _shell;
goto _fail;
}

printk(LOG_LEVEL_INFO, "EXTLINUX: load extlinux done, now booting...\n");

int bootdelay = CONFIG_DEFAULT_BOOTDELAY;
atf_head_t *atf_head = (atf_head_t *) image.bl31_dest;

/* Showing boot delays */
if (abortboot_single_key(bootdelay)) {
goto _shell;
}
atf_head->dtb_base = (uint32_t) image.of_dest;
atf_head->nos_base = (uint32_t) image.kernel_dest;

/* Fill platform magic */
memcpy(atf_head->platform, CONFIG_PLATFORM_MAGIC, 8);

printk(LOG_LEVEL_INFO, "ATF: Kernel addr: 0x%08x\n", atf_head->nos_base);
printk(LOG_LEVEL_INFO, "ATF: Kernel DTB addr: 0x%08x\n", atf_head->dtb_base);

clean_syterkit_data();

jmp_to_arm64(CONFIG_BL31_LOAD_ADDR);

printk(LOG_LEVEL_INFO, "Back to SyterKit\n");

// if kernel boot not success, jump to fel.
jmp_to_fel();

cmd_boot(0, NULL);
_fail:
LCD_Open_BLK();

_shell:
syterkit_shell_attach(commands);
abort();

return 0;
}
7 changes: 7 additions & 0 deletions include/drivers/sys-clk.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ uint32_t sunxi_clk_get_peri1x_rate();
*/
void sunxi_usb_clk_deinit();

/**
* @brief Change the cpu freq
*
* @param freq The freq of cpu want to set.
*/
void sunxi_clk_set_cpu_pll(uint32_t freq);

#ifdef __cplusplus
}
#endif // __cplusplus
Expand Down
6 changes: 2 additions & 4 deletions include/xformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ extern "C" {
#define XCFG_FORMAT_FLOAT 1

/**
* Define to 0 to support long long type (prefix ll)
* Define to 1 to support long long type (prefix ll)
*/
#ifndef XCFG_FORMAT_LONGLONG
#define XCFG_FORMAT_LONGLONG 0
#endif
#define XCFG_FORMAT_LONGLONG 1

/**
* Formats and outputs a string according to a format string 'fmt' and a variable argument list 'args'.
Expand Down
8 changes: 7 additions & 1 deletion scripts/genimage_t527_extlinux.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ image boot.vfat {
"sunxi.dtb",
"../board/avaota-a1/extlinux_boot/bl31/bl31.bin",
"../board/avaota-a1/extlinux_boot/scp/scp.bin",
"../board/avaota-a1/extlinux_boot/extlinux"
"../board/avaota-a1/extlinux_boot/extlinux",
"../board/avaota-a1/extlinux_boot/splash/splash.bin"
}
}
size = 128M
Expand All @@ -31,4 +32,9 @@ image sdcard.img {
bootable = "true"
image = "boot.vfat"
}

partition rootfs {
partition-type = 0x83
image = "rootfs.ext4"
}
}
Loading

0 comments on commit fbbd5fd

Please sign in to comment.