Skip to content

hi3516cv500: kernel 5.0–7.0 compat for OSAL, init wrappers, and drivers#61

Merged
widgetii merged 1 commit intomainfrom
fix/cv500-kernel-7.0
May 5, 2026
Merged

hi3516cv500: kernel 5.0–7.0 compat for OSAL, init wrappers, and drivers#61
widgetii merged 1 commit intomainfrom
fix/cv500-kernel-7.0

Conversation

@widgetii
Copy link
Copy Markdown
Member

Summary

Comprehensive compat fixes enabling CV500 opensdk modules to build against Linux 5.0 through 7.0 kernels. Tested with hi3516av300_neo firmware variant on Linux 7.0-rc6 (upstream-patches kernel).

Per #51, CV500 has zero direct kernel API calls in blobs — everything goes through OSAL. This PR ports the OSAL and all source-compiled modules to the modern kernel API.

Key changes (95 files, +651 −242):

  • OSAL: 20+ kernel API compat fixes via kernel_compat.h macros (access_ok, timer_setup, proc_ops, vm_flags, strlcpy, DEFINE_SEMAPHORE, etc.)
  • MMZ: Drop vendor hisi_allocator (not in mainline), use CMA-only on 5.16+. Replace __dma_clear_buffer, __pte_offset_map, hisi_get_cma_zone with mainline equivalents.
  • Init wrappers: platform_driver.remove void return (6.11+), MODULE_LICENSE("GPL"), ctl_table.child removal (6.6+) — all 31 files.
  • Drivers: sensor_i2c, sensor_spi, pwm, piris, cipher, ISP init — various API renames and signature changes.
  • Build system: -isystem for GCC stdarg.h, stub .cmd files for prebuilt blobs (modpost 7.0), printk shim for 4.9-era blob symbol linkage.
  • CI: Add hi3516av300_neo (CV500 7.0) build target.

Test plan

  • CI builds pass for existing platforms (no regressions — compat macros are version-gated)
  • hi3516av300_neo opensdk modules compile against Linux 7.0-rc6
  • hi3516cv500_lite (4.9.37 kernel) still builds correctly
  • Module load test on real hi3516av300 hardware

🤖 Generated with Claude Code

Comprehensive compat fixes enabling the CV500 opensdk modules to build
against modern Linux kernels (tested with 7.0-rc6 via hi3516av300_neo).

OSAL (osal/hi3516cv500/):
- access_ok 3→2 args (5.0+)
- set_fs/get_fs/get_ds removal (5.10+)
- platform_driver.remove void return (6.11+)
- vm_flags read-only (6.3+)
- get_random_int → get_random_u32 (6.1+)
- PDE_DATA → pde_data (5.17+)
- file_operations → proc_ops for /proc (5.6+)
- strlcpy → strscpy (6.8+)
- DEFINE_SEMAPHORE 2-arg (6.4+)
- timer_setup / from_timer (4.15+)
- do_gettimeofday removal (5.0+)
- rtc_time_to_tm / rtc_tm_to_time removal (5.6+)
- mmap_sem → mmap_lock (5.8+)
- ATTRIBUTE_GROUPS + const bus_type callbacks (7.0)
- list_for_each → osal_list_for_each for type safety (7.0)
- dma_alloc_from_contiguous 4th arg (4.15+)

MMZ (osal/hi3516cv500/mmz/):
- Drop hisi_allocator (vendor CMA, not in mainline); CMA-only on 5.16+
- __dma_clear_buffer → memset + cache flush (6.x+)
- __pte_offset_map → get_user_pages_fast (6.5+)
- hisi_get_cma_zone → dev_get_cma_area default CMA (5.16+)

Init wrappers (init/hi3516cv500/):
- platform_driver.remove void return in all 31 files
- MODULE_LICENSE "Proprietary" → "GPL" (printk GPL-only export 6.x+)
- MODULE_LICENSE added to jpegd_init
- ctl_table.child + register_sysctl_table removal (6.6+)

Drivers:
- sensor_i2c: hi_i2c_master_send → i2c_master_send, i2c_new_client_device
- sensor_spi: spi_busnum_to_controller, const spi_bus_type (7.0)
- pwm/piris: timer_setup, PTR_ERR case fix, platform_remove
- cipher: proc_ops, of_dma_configure 3-arg (4.18+), platform_remove
- ISP init: platform_remove
- hi_user: disabled (sched_setscheduler not exported on 6.x+)

Build system:
- Kbuild: -isystem for GCC built-in includes (stdarg.h under -nostdinc)
- obj/hi3516cv500: stub .cmd files for prebuilt blobs (modpost 7.0)
- printk shim in OSAL for 4.9-era blobs referencing old symbol name

CI:
- Add hi3516av300_neo (CV500 7.0 kernel) build target

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@widgetii widgetii force-pushed the fix/cv500-kernel-7.0 branch from 81e0073 to 680085e Compare May 4, 2026 15:27
widgetii added a commit to OpenIPC/firmware that referenced this pull request May 4, 2026
Add a "neo" variant for the hi3516av300 board running OpenIPC on the
upstream-patches kernel branch (Linux 7.0+) instead of the vendor
4.9.37 kernel. Per OpenIPC/openhisilicon#51, the CV500 platform has
zero direct kernel API calls in blobs — everything goes through OSAL,
making it a top-priority candidate for kernel modernization.

New files:
- br-ext-chip-hisilicon/configs/hi3516av300_neo_defconfig
  Buildroot defconfig with glibc toolchain, 16MB flash, upstream-patches
  kernel, BR2_OPENIPC_VARIANT="neo".
- br-ext-chip-hisilicon/board/hi3516cv500/hi3516av300.neo.config
  Seed kernel config with ARCH_HI3516DV300, COMMON_CLK_HI3516DV300,
  earlycon at 0x120a0000, ZRELADDR=0x80008000, CMA, MTD/SPI-NOR.
  Aggressive size trimming (no IPv6, no NETFILTER, no input/sound/USB,
  no JFFS2/CRAMFS/loop/RAM block) keeps uImage under 2048KB limit.
- br-ext-chip-hisilicon/board/hi3516cv500/neo-post-image.sh
  Concatenates zImage + DTB and wraps as uImage (load 0x80008000).

Modified packages:
- hisilicon-opensdk.mk: Replace 6 hardcoded kernel versions
  (3.0.8/3.18.20/4.9.37) with dynamic `kernel.release` detection,
  bump to OpenIPC/openhisilicon#61 commit (Linux 5.0-7.0 compat).
- hisilicon-osdrv-hi3516cv500.mk: Same dynamic kernel version.
- load_hisilicon: `uname -r` instead of hardcoded 4.9.37.

Tested:
- QEMU: U-Boot → Linux 7.0 → squashfs rootfs from MTD → login
- Real hardware (hi3516av300/MX25L256 32MB flash): builds and flashes
  via sysupgrade

Companion changes:
- openipc/linux upstream-patches: ARCH_HI3516DV300 DTS, CV500/DV300
  clock drivers, mach machine descriptor
- OpenIPC/openhisilicon#61: Linux 5.0-7.0 OSAL compat
- widgetii/qemu-hisilicon#33: CV500 SMP + flash boot

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
widgetii added a commit to OpenIPC/firmware that referenced this pull request May 5, 2026
Add a "neo" variant for the hi3516av300 board running OpenIPC on the
upstream-patches kernel branch (Linux 7.0+) instead of the vendor
4.9.37 kernel. Per OpenIPC/openhisilicon#51, the CV500 platform has
zero direct kernel API calls in blobs — everything goes through OSAL,
making it a top-priority candidate for kernel modernization.

New files:
- br-ext-chip-hisilicon/configs/hi3516av300_neo_defconfig
  Buildroot defconfig with glibc toolchain, 16MB flash, upstream-patches
  kernel, BR2_OPENIPC_VARIANT="neo".
- br-ext-chip-hisilicon/board/hi3516cv500/hi3516av300.neo.config
  Seed kernel config with ARCH_HI3516DV300, COMMON_CLK_HI3516DV300,
  earlycon at 0x120a0000, ZRELADDR=0x80008000, CMA, MTD/SPI-NOR.
  Aggressive size trimming (no IPv6, no NETFILTER, no input/sound/USB,
  no JFFS2/CRAMFS/loop/RAM block) keeps uImage under 2048KB limit.
- br-ext-chip-hisilicon/board/hi3516cv500/neo-post-image.sh
  Concatenates zImage + DTB and wraps as uImage (load 0x80008000).

Modified packages:
- hisilicon-opensdk.mk: Replace 6 hardcoded kernel versions
  (3.0.8/3.18.20/4.9.37) with dynamic `kernel.release` detection,
  bump to OpenIPC/openhisilicon#61 commit (Linux 5.0-7.0 compat).
- hisilicon-osdrv-hi3516cv500.mk: Same dynamic kernel version.
- load_hisilicon: `uname -r` instead of hardcoded 4.9.37.

Tested:
- QEMU: U-Boot → Linux 7.0 → squashfs rootfs from MTD → login
- Real hardware (hi3516av300/MX25L256 32MB flash): builds and flashes
  via sysupgrade

Companion changes:
- openipc/linux upstream-patches: ARCH_HI3516DV300 DTS, CV500/DV300
  clock drivers, mach machine descriptor
- OpenIPC/openhisilicon#61: Linux 5.0-7.0 OSAL compat
- widgetii/qemu-hisilicon#33: CV500 SMP + flash boot

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@widgetii widgetii merged commit bad4243 into main May 5, 2026
45 of 46 checks passed
@widgetii widgetii deleted the fix/cv500-kernel-7.0 branch May 5, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants