I met a problem when I launched the android emulator after build aosp successfully, emulator showed a black screen. Have you met this problem before?
this is my environment
CPU: AMD Ryzen 7 4800H
MEM: 32GB DDR 3200 MHZ
Build in: VMWare with AMD-V enabled (Windows 10 without Hyper-v): Ubuntu 20.04
Branch: android-11.0.0_r17
Target: aosp_cf_x86_phone-userdebug
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=11
TARGET_PRODUCT=aosp_cf_x86_phone
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=x86
TARGET_ARCH_VARIANT=x86
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-56-generic-x86_64-Ubuntu-20.04.1-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=RP1A.201105.002
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/generic/goldfish-opengl hardware/google/camera hardware/google/camera/devices/EmulatedCamera external/mesa3d
This is emulator logs:
dvdface#ubuntu:~/Source/aosp$ emulator -verbose emulator: Android
emulator version 30.0.21.0 (build_id 6647651) (CL:N/A) emulator: Found
ANDROID_PRODUCT_OUT:
/home/dvdface/Source/aosp/out/target/product/vsoc_x86 emulator: Found
build target architecture: x86 emulator: argv[0]: 'emulator'; program
directory:
'/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64'
emulator: emuDirName:
'/home/dvdface/Source/aosp/prebuilts/android-emulator/emulator'
emulator: Probing for
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/kernel-ranchu-64:
file missing emulator: try dir
/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64
emulator: Trying emulator path
'/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386'
emulator: Found target-specific 64-bit emulator binary:
/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386
emulator: Adding library search path:
'/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/lib64'
emulator: Adding library search path:
'/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/lib64/gles_angle'
emulator: Adding library search path:
'/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/lib64/gles_angle9'
emulator: Adding library search path:
'/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/lib64/gles_angle11'
emulator: Adding library search path:
'/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/lib64/gles_swiftshader'
emulator: Adding library search path:
'/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/lib64/libstdc++'
emulator: Adding library search path for Qt:
'/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/lib64/qt/lib'
emulator: Silencing all qWarning(); use qCWarning(...) instead:
QT_LOGGING_RULES=default.warning=false emulator: Setting Qt plugin
search path:
QT_QPA_PLATFORM_PLUGIN_PATH=/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/lib64/qt/plugins
emulator: Setting Qt to use software OpenGL: QT_OPENGL=software
emulator: Setting QML to use software QtQuick2D:
QMLSCENE_DEVICE=softwarecontext emulator: Overriding pre-existing bad
Qt high dpi settings... emulator: Setting LD_PRELOAD to
/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/lib64/qt/lib/libfreetype.so.6
emulator: Running
:/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386
emulator: qemu backend: argv[00] =
"/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386"
emulator: qemu backend: argv[01] = "-verbose" emulator: Concatenated
backend parameters:
/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386
-verbose emulator: found Android build root: /home/dvdface/Source/aosp emulator: found Android build out:
/home/dvdface/Source/aosp/out/target/product/vsoc_x86 emulator: Cannot
find boot properties file:
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/boot.prop
emulator: Found target API sdkVersion: 30
emulator: Invalid int property:
'ro.build.version.incremental:eng.dvdfac.20201204.223437' emulator:
autoconfig: -skin HVGA emulator: autoconfig: -skindir
/home/dvdface/Source/aosp/development/tools/emulator/skins/ emulator:
autoconfig: -kernel
/home/dvdface/Source/aosp/prebuilts/qemu-kernel/x86/ranchu/kernel-qemu
emulator: Target arch = 'x86' emulator: Auto-config: -qemu -cpu qemu32
emulator: Auto-detect: Kernel image requires new device naming scheme.
emulator: Auto-detect: Kernel does not support YAFFS2 partitions.
emulator: autoconfig: -ramdisk
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/ramdisk.img
emulator: autoconfig: -sysdir
/home/dvdface/Source/aosp/out/target/product/vsoc_x86 emulator: Using
initial system image:
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/system.img
emulator: Using initial vendor image:
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/vendor.img
emulator: autoconfig: -data
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/userdata-qemu.img
emulator: autoconfig: -initdata
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/userdata.img
emulator: autoconfig: -cache
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/cache.img
emulator: Increasing RAM size to 2048MB emulator: VM heap size 48MB is
below hardware specified minimum of 512MB,setting it to that value
emulator: System image is read only emulator: Found 1 DNS servers:
127.0.0.53 emulator: trying to load skin file '/home/dvdface/Source/aosp/development/tools/emulator/skins//HVGA/layout'
emulator: WARNING: encryption is off emulator: CPU Acceleration:
working emulator: CPU Acceleration status: KVM (version 12) is
installed and usable. emulator: GPU emulation enabled using 'host'
mode emulator: Initializing hardware OpenGLES emulation support
emulator: VERBOSE: MultiDisplay.cpp:304: create display 0 emulator:
VERBOSE: MultiDisplay.cpp:394: setDisplayPose 0 x 0 y 0 w 320 h 480
dpi 0 emulator: VERBOSE: load_config.cpp:242: Verified boot params
were not found. emulator: Found 1 DNS servers: 127.0.0.53 Content of
hardware configuration file: hw.cpu.arch = x86 hw.cpu.model =
qemu32 hw.cpu.ncore = 2 hw.ramSize = 2048 hw.screen =
multi-touch hw.mainKeys = true hw.trackBall = true hw.keyboard =
false hw.keyboard.lid = false hw.keyboard.charmap = qwerty2
hw.dPad = true hw.rotaryInput = false hw.gsmModem = true hw.gps
= true hw.battery = true hw.accelerometer = true hw.gyroscope = true hw.audioInput = true hw.audioOutput = true hw.sdCard = true
disk.cachePartition = true disk.cachePartition.path =
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/cache.img
disk.cachePartition.size = 66m test.quitAfterBootTimeOut = -1
test.delayAdbTillBootComplete = 0 test.monitorAdb = 0 hw.lcd.width
= 320 hw.lcd.height = 480 hw.lcd.depth = 16 hw.lcd.density = 160 hw.lcd.backlight = true hw.lcd.vsync = 60 hw.gltransport = pipe
hw.gltransport.asg.writeBufferSize = 1048576
hw.gltransport.asg.writeStepSize = 4096
hw.gltransport.asg.dataRingSize = 32768
hw.gltransport.drawFlushInterval = 800 hw.displayRegion.0.1.xOffset
= -1 hw.displayRegion.0.1.yOffset = -1 hw.displayRegion.0.1.width = 0 hw.displayRegion.0.1.height = 0 hw.display1.width = 0 hw.display1.height = 0 hw.display1.density = 0 hw.display1.xOffset
= -1 hw.display1.yOffset = -1 hw.display1.flag = 0 hw.display2.width = 0 hw.display2.height = 0 hw.display2.density =
0 hw.display2.xOffset = -1 hw.display2.yOffset = -1
hw.display2.flag = 0 hw.display3.width = 0 hw.display3.height = 0
hw.display3.density = 0 hw.display3.xOffset = -1
hw.display3.yOffset = -1 hw.display3.flag = 0 hw.gpu.enabled =
true hw.gpu.mode = host hw.initialOrientation = portrait
hw.camera.back = emulated hw.camera.front = none vm.heapSize = 512
hw.sensors.light = true hw.sensors.pressure = true
hw.sensors.humidity = true hw.sensors.proximity = true
hw.sensors.magnetic_field = true
hw.sensors.magnetic_field_uncalibrated = true
hw.sensors.gyroscope_uncalibrated = true hw.sensors.orientation =
true hw.sensors.temperature = true hw.sensor.hinge = false
hw.sensor.hinge.count = 0 hw.sensor.hinge.type = 0 hw.useext4 =
true hw.arc = false hw.arc.autologin = false kernel.path =
/home/dvdface/Source/aosp/prebuilts/qemu-kernel/x86/ranchu/kernel-qemu
kernel.newDeviceNaming = yes kernel.supportsYaffs2 = no
disk.ramdisk.path =
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/ramdisk.img
disk.systemPartition.initPath =
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/system.img
disk.systemPartition.size = 800m disk.vendorPartition.initPath =
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/vendor.img
disk.vendorPartition.size = 800m disk.dataPartition.path =
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/userdata-qemu.img
disk.dataPartition.size = 800m PlayStore.enabled = false avd.name
= avd.id = fastboot.forceColdBoot = false android.avd.home = /home/dvdface/.android/avd . QEMU options list:
emulator: argv[00] =
"/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386"
emulator: argv[01] = "-dns-server" emulator: argv[02] = "127.0.0.53"
emulator: argv[03] = "-serial" emulator: argv[04] = "null" emulator:
argv[05] = "-device" emulator: argv[06] =
"goldfish_pstore,addr=0xff018000,size=0x10000,file=/home/dvdface/Source/aosp/out/target/product/vsoc_x86/build.avd/data/misc/pstore/pstore.bin"
emulator: argv[07] = "-cpu" emulator: argv[08] = "android32" emulator:
argv[09] = "-enable-kvm" emulator: argv[10] = "-smp" emulator:
argv[11] = "cores=2" emulator: argv[12] = "-m" emulator: argv[13] =
"2048" emulator: argv[14] = "-lcd-density" emulator: argv[15] = "160"
emulator: argv[16] = "-object" emulator: argv[17] =
"iothread,id=disk-iothread" emulator: argv[18] = "-nodefaults"
emulator: argv[19] = "-kernel" emulator: argv[20] =
"/home/dvdface/Source/aosp/prebuilts/qemu-kernel/x86/ranchu/kernel-qemu"
emulator: argv[21] = "-initrd" emulator: argv[22] =
"/home/dvdface/Source/aosp/out/target/product/vsoc_x86/ramdisk.img"
emulator: argv[23] = "-drive" emulator: argv[24] =
"if=none,index=0,id=system,if=none,file=/home/dvdface/Source/aosp/out/target/product/vsoc_x86/system.img,read-only"
emulator: argv[25] = "-device" emulator: argv[26] =
"virtio-blk-pci,drive=system,iothread=disk-iothread,modern-pio-notify"
emulator: argv[27] = "-drive" emulator: argv[28] =
"if=none,index=1,id=cache,if=none,file=/home/dvdface/Source/aosp/out/target/product/vsoc_x86/cache.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576"
emulator: argv[29] = "-device" emulator: argv[30] =
"virtio-blk-pci,drive=cache,iothread=disk-iothread,modern-pio-notify"
emulator: argv[31] = "-drive" emulator: argv[32] =
"if=none,index=2,id=userdata,if=none,file=/home/dvdface/Source/aosp/out/target/product/vsoc_x86/userdata-qemu.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576" emulator: argv[33] = "-device" emulator: argv[34] =
"virtio-blk-pci,drive=userdata,iothread=disk-iothread,modern-pio-notify"
emulator: argv[35] = "-drive" emulator: argv[36] =
"if=none,index=3,id=vendor,if=none,file=/home/dvdface/Source/aosp/out/target/product/vsoc_x86/vendor.img,read-only"
emulator: argv[37] = "-device" emulator: argv[38] =
"virtio-blk-pci,drive=vendor,iothread=disk-iothread,modern-pio-notify"
emulator: argv[39] = "-netdev" emulator: argv[40] = "user,id=mynet"
emulator: argv[41] = "-device" emulator: argv[42] =
"virtio-net-pci,netdev=mynet" emulator: argv[43] = "-device" emulator:
argv[44] = "virtio-rng-pci" emulator: argv[45] = "-show-cursor"
emulator: argv[46] = "-L" emulator: argv[47] =
"/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/lib/pc-bios"
emulator: argv[48] = "-soundhw" emulator: argv[49] = "hda" emulator:
argv[50] = "-vga" emulator: argv[51] = "none" emulator: argv[52] =
"-append" emulator: argv[53] = "qemu=1 no_timer_check
androidboot.hardware=ranchu androidboot.serialno=EMULATOR30X0X21X0
clocksource=pit no-kvmclock android.qemud=1 console=0
android.checkjni=1 qemu.gles=1
qemu.settings.system.screen_off_timeout=2147483647 qemu.vsync=60
qemu.gltransport=pipe qemu.gltransport.drawFlushInterval=800
qemu.opengles.version=131072 cma=4M#0-4G
androidboot.android_dt_dir=/sys/bus/platform/devices/ANDR0001:00/properties/android/
loop.max_part=7 ramoops.mem_address=0xff018000
ramoops.mem_size=0x10000 memmap=0x10000$0xff018000
qemu.dalvik.vm.heapsize=512m qemu.camera_protocol_ver=1" emulator:
argv[54] = "-android-hw" emulator: argv[55] =
"/home/dvdface/Source/aosp/out/target/product/vsoc_x86/hardware-qemu.ini"
Concatenated QEMU options:
/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386
-dns-server 127.0.0.53 -serial null -device goldfish_pstore,addr=0xff018000,size=0x10000,file=/home/dvdface/Source/aosp/out/target/product/vsoc_x86/build.avd/data/misc/pstore/pstore.bin
-cpu android32 -enable-kvm -smp cores=2 -m 2048 -lcd-density 160 -object iothread,id=disk-iothread -nodefaults -kernel /home/dvdface/Source/aosp/prebuilts/qemu-kernel/x86/ranchu/kernel-qemu
-initrd /home/dvdface/Source/aosp/out/target/product/vsoc_x86/ramdisk.img
-drive if=none,index=0,id=system,if=none,file=/home/dvdface/Source/aosp/out/target/product/vsoc_x86/system.img,read-only
-device virtio-blk-pci,drive=system,iothread=disk-iothread,modern-pio-notify
-drive if=none,index=1,id=cache,if=none,file=/home/dvdface/Source/aosp/out/target/product/vsoc_x86/cache.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576
-device virtio-blk-pci,drive=cache,iothread=disk-iothread,modern-pio-notify
-drive if=none,index=2,id=userdata,if=none,file=/home/dvdface/Source/aosp/out/target/product/vsoc_x86/userdata-qemu.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576
-device virtio-blk-pci,drive=userdata,iothread=disk-iothread,modern-pio-notify
-drive if=none,index=3,id=vendor,if=none,file=/home/dvdface/Source/aosp/out/target/product/vsoc_x86/vendor.img,read-only
-device virtio-blk-pci,drive=vendor,iothread=disk-iothread,modern-pio-notify
-netdev user,id=mynet -device virtio-net-pci,netdev=mynet -device virtio-rng-pci -show-cursor -L
/home/dvdface/Source/aosp/prebuilts/android-emulator/linux-x86_64/lib/pc-bios
-soundhw hda -vga none -append 'qemu=1 no_timer_check androidboot.hardware=ranchu androidboot.serialno=EMULATOR30X0X21X0
clocksource=pit no-kvmclock android.qemud=1 console=0
android.checkjni=1 qemu.gles=1
qemu.settings.system.screen_off_timeout=2147483647 qemu.vsync=60
qemu.gltransport=pipe qemu.gltransport.drawFlushInterval=800
qemu.opengles.version=131072 cma=4M#0-4G
androidboot.android_dt_dir=/sys/bus/platform/devices/ANDR0001:00/properties/android/
loop.max_part=7 ramoops.mem_address=0xff018000
ramoops.mem_size=0x10000 memmap=0x10000$0xff018000
qemu.dalvik.vm.heapsize=512m qemu.camera_protocol_ver=1' -android-hw
/home/dvdface/Source/aosp/out/target/product/vsoc_x86/hardware-qemu.ini
emulator: Android qemu version 30.0.21.0 (build_id 6647651) (CL:N/A)
emulator: Starting QEMU main loop emulator: registered
'boot-properties' qemud service emulator: Adding boot property:
'ro.opengles.version' = '131072' emulator: Adding boot property:
'qemu.sf.fake_camera' = 'back' emulator: Adding boot property:
'dalvik.vm.heapsize' = '512m' emulator: Adding boot property:
'qemu.hw.mainkeys' = '1' emulator: Adding boot property:
'qemu.sf.lcd_density' = '160' emulator: goldfish_events.have-dpad:
true emulator: goldfish_events.have-trackball: true emulator:
goldfish_events.have-camera: true emulator:
goldfish_events.have-keyboard: false emulator:
goldfish_events.have-lidswitch: false emulator:
goldfish_events.have-tabletmode: false emulator:
goldfish_events.have-touch: false emulator:
goldfish_events.have-multitouch: true emulator: control console
listening on port 5554, ADB on port 5555 Not using any http proxy
emulator: Adding boot property: 'qemu.timezone' =
'America/Los_Angeles' emulator: android_hw_fingerprint_init:
fingerprint qemud listen service initialized
emulator: VERBOSE: GrpcServices.cpp:279: Started GRPC server at
127.0.0.1:8554, security: Local emulator: emulator_window_fb_rotate
emulator: VERBOSE: AdbInterface.cpp:355: no root specified:
emulator: VERBOSE: AdbInterface.cpp:355: no root specified:
emulator: VERBOSE: AdbInterface.cpp:385: Found: 1 adb executables
emulator: VERBOSE: AdbInterface.cpp:387: Adb:
/home/dvdface/Source/aosp/out/soong/host/linux-x86/bin/adb emulator:
No acpi ini file provided, using default
emulator: VERBOSE: AdbInterface.cpp:408:
Path:/home/dvdface/Source/aosp/out/soong/host/linux-x86/bin/adb
protocol version: 41 emulator: Adding boot property:
'ro.opengles.version' = '131072' emulator: Adding boot property:
'qemu.sf.fake_camera' = 'back' emulator: Adding boot property:
'dalvik.vm.heapsize' = '512m' emulator: Adding boot property:
'qemu.hw.mainkeys' = '1' emulator: Adding boot property:
'qemu.sf.lcd_density' = '160' emulator: Adding boot property:
'qemu.timezone' = 'America/Los_Angeles' emulator: No acpi ini file
provided, using default
emulator: No acpi ini file provided, using default
emulator: No acpi ini file provided, using default
emulator: No acpi ini file provided, using default
Related
I have upgraded my server in my Dev environment to version 18. We have a requirement of using a JavaScript authenticator.
As per the new documentation, I have created a JAR file and copied it in /providers directory and did a kc.sh build --features=scripts.
I get the following output (the one in bold is the JAR file for JS authenicator), However in the GUI I do not see my script under authenticator.
What else is required to use JS authenticator?
root#2f50c05d580b:/opt/keycloak/keycloak-18.0.2/providers# ../bin/kc.sh show-config
Current Mode: none
Runtime Configuration:
kc.cache = ispn (PersistedConfigSource)
kc.config.args = show-config (SysPropConfigSource)
kc.db = dev-file (PersistedConfigSource)
kc.features = preview (PersistedConfigSource)
kc.health-enabled = false (PersistedConfigSource)
kc.home.dir = /opt/keycloak/keycloak-18.0.2/bin/../ (SysPropConfigSource)
kc.http-enabled = false (PropertiesConfigSource[source=jar:file:///opt/keycloak/keycloak-18.0.2/lib/lib/main/org.keycloak.keycloak-quarkus-server-18.0.2.jar!/META-INF/keycloak.conf])
kc.http-relative-path = / (PersistedConfigSource)
kc.log-console-output = default (PropertiesConfigSource[source=jar:file:///opt/keycloak/keycloak-18.0.2/lib/lib/main/org.keycloak.keycloak-quarkus-server-18.0.2.jar!/META-INF/keycloak.conf])
kc.log-file = /opt/keycloak/keycloak-18.0.2/bin/../data/log/keycloak.log (PropertiesConfigSource[source=jar:file:///opt/keycloak/keycloak-18.0.2/lib/lib/main/org.keycloak.keycloak-quarkus-server-18.0.2.jar!/META-INF/keycloak.conf])
kc.metrics-enabled = false (PersistedConfigSource)
kc.provider.file.ammauth3.jar.last-modified = 1658319279100 (PersistedConfigSource)
kc.quarkus-properties-enabled = false (PersistedConfigSource)
kc.show.config = none (SysPropConfigSource)
kc.version = 18.0.2 (SysPropConfigSource)
I have a simple program that uses ADC to convert 2 inputs, I use DMA in circular mode. Everything works great. The only problem I have is that in order to reflash the STM32, I have to first erase the chip. This is only happening when I set the ADC to circular mode.
Hopefully someone can help with this. Thanks!
Here is the code for setting up DMA/ADC
void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if (hadc->Instance == ADC1)
{
__HAL_RCC_ADC1_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
hdma_adc1.Instance = DMA2_Stream0;
hdma_adc1.Init.Channel = DMA_CHANNEL_0;
hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;
hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
hdma_adc1.Init.Mode = DMA_CIRCULAR;
hdma_adc1.Init.Priority = DMA_PRIORITY_LOW;
hdma_adc1.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
hdma_adc1.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_HALFFULL;
if (HAL_DMA_Init(&hdma_adc1) != HAL_OK)
{
Error_Handler();
}
__HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1);
}
}
void MX_ADC1_Init(void)
{
ADC_ChannelConfTypeDef sConfig = {0};
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.ScanConvMode = ENABLE;
hadc1.Init.ContinuousConvMode = ENABLE;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.NbrOfConversion = 2;
hadc1.Init.DMAContinuousRequests = ENABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_8;
sConfig.Rank = 1;
sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_9;
sConfig.Rank = 2;
sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
}
And here is the output from jlink. Again, if I erase the chip everything works fine.
/Applications/SEGGER/JLink_V686c/JLinkGDBServerCLExe -select USB -device STM32F401RE -endian
little -if SWD -speed auto -ir -noLocalhostOnly
SEGGER J-Link GDB Server V6.86c Command Line Version
JLinkARM.dll V6.86c (DLL compiled Oct 6 2020 14:16:39)
Command line: -select USB -device STM32F401RE -endian little -if SWD -speed auto -ir -
noLocalhostOnly
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: on
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: STM32F401RE
Target interface: SWD
Target interface speed: auto
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link EDU Mini V1 compiled Oct 2 2020 17:00:40
Hardware: V1.00
S/N: 801018944
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.28 V
Listening on TCP/IP port 2331
Connecting to target...
Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 2 bytes # address 0x0800EF10 (Data = 0xB508)
Read 2 bytes # address 0x080080A0 (Data = 0x4770)
Read 4 bytes # address 0x00000000 (Data = 0x20018000)
Read 2 bytes # address 0x00000000 (Data = 0x8000)
Downloading 408 bytes # address 0x08000000
Downloading 16048 bytes # address 0x080001C0
Downloading 16144 bytes # address 0x08004070
Downloading 16048 bytes # address 0x08007F80
Downloading 15968 bytes # address 0x0800BE30
Downloading 16000 bytes # address 0x0800FC90
Downloading 7876 bytes # address 0x08013B10
Downloading 5908 bytes # address 0x080159D8
Downloading 956 bytes # address 0x080170EC
Downloading 1032 bytes # address 0x080174A8
Downloading 24 bytes # address 0x080178B0
Downloading 4 bytes # address 0x080178C8
Downloading 2496 bytes # address 0x080178CC
ERROR: Failed to prepare for programming.
RAM check failed # addr 0x20000E6C.
RAM check failed while testing 0x1050 bytes # addr 0x200006CC.
Writing register (PC = 0x 800c8f0)
Read 2 bytes # address 0x0800EF10 (Data = 0xB508)
Read 2 bytes # address 0x080080A0 (Data = 0x4770)
Received monitor command: reset
Resetting target
Resetting target
Debugger connected to 127.0.0.1:2331
Starting target CPU...
We have code in a Xamarin App using bar code scanning. It has been working successfully for 3 years. We have found an issue with the iPhone 11 pro and its three camera setup.
_captureSession = new AVCaptureSession();
CameraMetaDataDelegate del = null;
AVCaptureDevice captureDevice =
AVCaptureDevice.GetDefaultDevice(AVMediaType.Video);
if (captureDevice != null)
{
var videoInput = AVCaptureDeviceInput.FromDevice(captureDevice, out error);
if (videoInput != null) { _captureSession.AddInput(videoInput); }
else { iApp.Log.Error("Video capture error: " + error.LocalizedDescription); }
var metaDataOutput = new AVCaptureMetadataOutput();
_captureSession.AddOutput(metaDataOutput);
del = new CameraMetaDataDelegate(this, _layer);
metaDataOutput.SetDelegate(del, CoreFoundation.DispatchQueue.MainQueue);
metaDataOutput.MetadataObjectTypes = metaDataOutput.AvailableMetadataObjectTypes;
_videoPreviewLayer = new AVCaptureVideoPreviewLayer(_captureSession) {
Frame = View.Bounds,
Orientation = (AVCaptureVideoOrientation)InterfaceOrientation,
};
View.Layer.AddSublayer(_videoPreviewLayer);
...
We have the the necessary entitlements in the info.plist
<key>NSCameraUsageDescription</key>
<string>Scan Barcodes</string>
It seems to be crashing on the AVCaptureDeviceInput. The "Application would like access to the camera" popup remains on the screen after the crash.
This works on older iPhones. We have not tried on an iPhone 11 non-pro.
Log looks like this
default 17:46:52.725211 -0500 tccd PID[30] is checking access for target PID[933]
default 17:46:52.734801 -0500 mediaserverd Updating configuration of monitor <RBSProcessMonitorConfiguration: 0x10cc25430; id: M30-27; qos: 25> {
predicates = {
<RBSProcessPredicate: 0x103735f30> {
predicate = <RBSCompoundPredicate; <RBSCompoundPredicate; <RBSProcessEUIDPredicate; 501>; <RBSProcessBKSLegacyPredicate: 0x103104870>>; <RBSProcessBundleIdentifierPredicate; com.apple.InCallService>>;
};
}
descriptor = <RBSProcessStateDescriptor: 0x10cc46300; values: 11> {
namespaces = {
com.apple.frontboard.visibility;
}
};
}
default 17:46:52.735816 -0500 mediaserverd BKSApplicationStateMonitor updated with invalid process
default 17:46:52.736059 -0500 runningboardd [daemon<com.apple.mediaserverd>:30] handle lookup could not find a matching process
default 17:46:52.736188 -0500 mediaserverd <<<< FigCaptureClientSessionMonitor >>>> -[FigCaptureClientSessionMonitor _updateClientStateCondition:newValue:]: <private> Updating client with application state "Foregrounded" and layout state "None"
default 17:46:52.736343 -0500 mediaserverd <<<< FigCaptureSession >>>> captureSession_updateRunningCondition: <0x102eddb90> (PID:933): ClientStartedSession:0 Cam/Audio:0/0 bg:0 prewarming:0 int:0 windowed:0 devStolen:0, pressured:0, active:0 shouldRun:0, start:0 stop:0 stopRecordingIfActive:0
default 17:46:52.746798 -0500 mediaserverd Creating remote service object
default 17:46:52.748227 -0500 applecamerad <private>
default 17:46:52.748255 -0500 applecamerad <private>
default 17:46:52.748282 -0500 applecamerad <private>
default 17:46:52.748314 -0500 applecamerad <private>
default 17:46:52.748348 -0500 applecamerad H10ISPFlickerDetectorCreate - HWType = 3; pContext = 0x104c0e830
default 17:46:52.748377 -0500 applecamerad FlickerDetector: ArbiterClient resource access granted=1
default 17:46:52.749880 -0500 mediaserverd 2325: [volm/inpt/0] on device [ type: vhaw; id: 233; addr: 0x109a33d60; hidden: 0; VA strms: { i/238/0x109a34bc0, }; agg dev: [ id: 203; addr: 0x10c38d800; uid: "VAD [vhaw] AggDev 6"; virt strms: { }; phys devs: { [ id: 94; addr: 0x102e1af80; uid: "Hawking"; streams: { i/95/0x102e1b2d0, } ] } ] ]: 1.000000.
default 17:46:52.749914 -0500 mediaserverd 161: Setting Input Volume: 18.000000 dB, Final HW Volume: 18.000000 dB, Final SW Volume: 0.000000 dB
default 17:46:52.749945 -0500 mediaserverd 162: PhysicalDevice UID = "Hawking"
default 17:46:52.750012 -0500 mediaserverd 163: Scope = 1768845428 ("inpt")
default 17:46:52.750041 -0500 mediaserverd 164: Element = 0 ("0")
default 17:46:52.750405 -0500 applecamerad AURemoteIO.cpp:1546:Start: Starting AURemoteIO(0x107008c40)
output client: 1 ch, 0 Hz, Float32, output HW: 1 ch, 0 Hz, Float32
input client: 2 ch, 16000 Hz, Float32, inter, input HW: 2 ch, 16000 Hz, Float32, non-inter
default 17:46:52.750485 -0500 applecamerad AURemoteIO.cpp:1556:Start: work interval port 0x607b
default 17:46:52.751151 -0500 mediaserverd MEDeviceStreamClient.cpp:216:AddRunningClient: AQME device VirtualAudioDevice_Hawking: client starting: <RemoteIOClient#0x10500e600(#0x10500e658); input; CMSession(applecamerad[116])>; running count now 1
default 17:46:52.751186 -0500 mediaserverd 671: Client request to start IO proc ID 0x109a4abc0 on VAD 233.
default 17:46:52.751276 -0500 mediaserverd <<<< FigCaptureSession >>>> captureSession_SetConfiguration: <0x102eddb90> (PID:933): New configuration: <private>
default 17:46:52.751375 -0500 mediaserverd <<<< FigCaptureSession >>>> captureSession_updateRunningCondition: <0x102eddb90> (PID:933): ClientStartedSession:0 Cam/Audio:0/0 bg:0 prewarming:0 int:0 windowed:0 devStolen:0, pressured:0, active:0 shouldRun:0, start:0 stop:0 stopRecordingIfActive:0
default 17:46:52.751608 -0500 mediaserverd 599: Starting IO type 0 on AggregateDevice 203.
default 17:46:52.751655 -0500 mediaserverd HALS_IOContext::StartIOProcID: 206 Hawking (VAD [vhaw] AggDev 6):
default 17:46:52.753329 -0500 mediaserverd starting ProcID 0x21 state: Prewarm: 0 Play: 0 State: Stopped IOProc 0x21: no
default 17:46:52.753407 -0500 mediaserverd HALS_Device::_GetCombinedVolumeScalar: client 0 is not present and has a combined volume scalar is 1.000000
default 17:46:52.753633 -0500 mediaserverd <<<< FigCaptureSession >>>> captureSession_SetConfiguration: <0x102eddb90> (PID:933): New configuration: <private>
default 17:46:52.753700 -0500 CommCenter #I <private> request: <private>.
default 17:46:52.753812 -0500 mediaserverd <<<< FigCaptureSession >>>> captureSession_updateRunningCondition: <0x102eddb90> (PID:933): ClientStartedSession:0 Cam/Audio:1/0 bg:0 prewarming:0 int:0 windowed:0 devStolen:0, pressured:0, active:0 shouldRun:0, start:0 stop:0 stopRecordingIfActive:0
default 17:46:52.753934 -0500 CommCenter #I Received Audio State: <private>
default 17:46:52.753974 -0500 nfcd 00000001 57f02250 -[NFCameraStateMonitor _updateCameraStateValue:]:203 current=0, new=5
default 17:46:52.754014 -0500 mediaserverd 65: :413:: IOProc (AggregateDevice 203, IO type NonNullIOProc) running state is now running (2).
default 17:46:52.754047 -0500 nfcd 00000001 57f02250 -[NFCameraStateMonitor _updateCameraStateValue:]:203 current=5, new=7
default 17:46:52.754078 -0500 nfcd 00000001 57f02250 -[NFCameraStateMonitor _updateCameraStateValue:]:203 current=7, new=15
default 17:46:52.754405 -0500 backboardd Connection removed: IOHIDEventSystemConnection uuid:07F3B331-86A0-445F-ABA7-DDDA546740A7 pid:933 process:MYAPP5 type:Passive entitlements:0x0 caller:BackBoardServices: <redacted> + 384 attributes:{
HighFrequency = 1;
bundleID = "com.MYCOMPANY.mobile.MYAPP.development";
pid = 933;
} inactive:0 events:102 mask:0x800
default 17:46:52.754543 -0500 backboardd HIDAnalytics Unregister Send event com.apple.hid.queueUsage
default 17:46:52.755359 -0500 SpringBoard Workspace connection invalidated for <FBWorkspaceServer: 0x2822ce040>
default 17:46:52.755514 -0500 SpringBoard [application<com.MYCOMPANY.mobile.MYAPP.development>:933] Now flagged as pending exit for reason: workspace client connection invalidated
default 17:46:52.755776 -0500 SpringBoard Updating configuration of monitor <RBSProcessMonitorConfiguration: 0x2823ed600; id: M57-6; qos: 25> {
predicates = {
<RBSProcessPredicate: 0x283a521b0> {
predicate = <RBSCompoundPredicate; <RBSCompoundPredicate; <RBSProcessEUIDPredicate; 501>; <RBSProcessBKSLegacyPredicate: 0x283a40340>>; <RBSProcessBundleIdentifierPredicate; com.apple.springboard>>;
};
<RBSProcessPredicate: 0x283a5c2e0> {
predicate = <RBSCompoundPredicate; <RBSCompoundPredicate; <RBSProcessEUIDPredicate; 501>; <RBSProcessBKSLegacyPredicate: 0x283a40340>>; <RBSProcessBundleIdentifierPredicate; com.apple.MailCompositionService>>;
};
<RBSProcessPredicate: 0x283a5c2d0> {
predicate = <RBSCompoundPredicate; <RBSProcessBundleIdentifierPredicate; com.apple.ScreenshotServicesService>; <RBSCompoundPredicate; <RBSProcessEUIDPredicate; 501>; <RBSProcessBKSLegacyPredicate: 0x283a40340>>>;
};
<RBSProcessPredicate: 0x283a5d2e0> {
predicate = <RBSCompoundPredicate; <RBSCompou<…>
default 17:46:52.755823 -0500 SpringBoard connection invalidated
default 17:46:52.755869 -0500 SpringBoard connection invalidated
default 17:46:52.756102 -0500 CommCenter Client [<private>] disconnected (conn=0x101590a20), client list size 35
default 17:46:52.756159 -0500 locationd #Spi, Connection invalidated for process <private>
Not sure if it is another permissions issue, or using the wrong AV API, or need another preliminary step. Perhaps a race condition that should delay until camera responds available?
Junior Jiang's suggestion led me down the path to getting the iPhone 11 pro bar code scanning. First it really is necessary to check the authorization status, which used to fire on the first request before. Once this is established, then the camera will work. The second problem is that, at least in Xamarin C#, I could not assign the list of AvailableMetaDataObjectTypes. There is an earlier Stack Overflow which directs to use that list: Stack Overflow Xcode 9/Swift 4 AVCaptureMetadataOutput setMetadataObjectTypes use availableMetadataObjectTypes
But now the solution was to explicitly state which ones to use.
_captureSession = new AVCaptureSession();
CameraMetaDataDelegate del = null;
var authStatus = AVCaptureDevice.GetAuthorizationStatus(AVMediaType.Video);
AVCaptureDevice captureDevice = null;
// check authorization status
if (authStatus == AVAuthorizationStatus.Authorized)
{
captureDevice = AVCaptureDevice.GetDefaultDevice(AVMediaType.Video); // update for iOS 13
}
else if (authStatus == AVAuthorizationStatus.NotDetermined)
{
AVCaptureDevice.RequestAccessForMediaType(AVMediaType.Video, (granted) =>
{
if (!granted)
{
Log.Error("ViewDidLoadBase ScanLayer RequestAccessForMediaType not granted!");
}
else
{
Log.Error("ViewDidLoadBase ScanLayer RequestAccessForMediaType granted!");
}
});
}
else
{
Log.Error("Not Authorized! Status: " + authStatus.ToString());
}
if (captureDevice != null)
{
var videoInput = AVCaptureDeviceInput.FromDevice(captureDevice, out error);
if (videoInput != null)
{
_captureSession.AddInput(videoInput);
}
else
{
Log.Error("Video capture error: " + error.LocalizedDescription);
}
var metaDataOutput = new AVCaptureMetadataOutput();
_captureSession.AddOutput(metaDataOutput);
del = new CameraMetaDataDelegate(this, _layer);
metaDataOutput.SetDelegate(del, CoreFoundation.DispatchQueue.MainQueue);
//metaDataOutput.MetadataObjectTypes = metaDataOutput.AvailableMetadataObjectTypes;
metaDataOutput.MetadataObjectTypes = AVMetadataObjectType.QRCode | AVMetadataObjectType.Code128Code | AVMetadataObjectType.UPCECode | AVMetadataObjectType.EAN13Code ;
_videoPreviewLayer = new AVCaptureVideoPreviewLayer(_captureSession) {
Frame = View.Bounds,
Orientation = (AVCaptureVideoOrientation)InterfaceOrientation,
};
View.Layer.AddSublayer(_videoPreviewLayer);
I'm building an app with Flutter that allows me to record audio and then play it back later. I'm using the package audio_recorder 0.4.0 for recording the audio and the package stereo 1.0.0 for playing back the audio.
When I record using the iOS simulator, everything works fine. But when I run on the physical device (iPhone 6 Plus), I always get a 28 byte file at the end of the recording session - basically just a header to the m4a file.
I've tracked this down to some kind of interference between the two libraries. I can record on the physical device just fine if I use the sample app included with audio_recorder 0.4.0. But all I have to do is add the line stereo: 1.0.0 to the dependencies in pubspec.yml of that same sample project and suddenly I start getting the 28 byte files on the physical device at the end of a recording session instead of a normal size m4a file.
I have a two-part question:
What kind of interference could the stereo library be causing to make this kind of failure in the audio_recorder library? I suspected channel interference, but my attempt to isolate that didn't yield anything.
How can I track down what is causing this?
I have examined the console output from both sessions. When it is failing, I see several (8) of these lines in the the console output right after attempting to start recording:
mediaserverd 1111: AudioConverterNew returned -50
Others have suggested that this error occurs when there is no microphone available.
I also see this suspicious difference between the outputs.
When recording is broken:
default 11:36:57.098825 -0700 mediaserverd 4414: { "action":"set_play_state", "session":{"ID":"0x3315820","PID":14591,"name":"Runner"}, "details":"entry" }
default 11:36:57.100484 -0700 mediaserverd -CMSessionMgr- cmsSetIsPlaying: CMSession: 'sid:0x3315820, Runner(14591), 'prim'' with [MediaPlayback/Default] [NonMixable] [System Audio] starting playing.
default 11:36:57.104699 -0700 mediaserverd CAReportingClient.mm:328:-[CAReportingClient sendMessage:category:type:reporters:]: message {
Volume = "0.75";
VolumeCategory = "Audio/Video";
VolumeOperationProcess = "com.monkela.audioRecordSample";
VolumeOperationTime = 576708;
VolumePlayingState = 1;
}: (
857014545
)
default 11:36:57.105879 -0700 mediaserverd -CMVAEndptMgr- vaemSetDeviceVolume: CMSession: Setting cmsvolume = 0.750 for device ID: VirtualAudioDevice_Default
default 11:36:57.107295 -0700 mediaserverd VirtualAudio_Device.cpp:2046:SetPropertyData: [volm/outp/0] on device [ type: vdef; id: 354; addr: 0x1014e1ba0; hidden: 0; VA strms: { o/883/0x106fc5980 }; agg dev: [ id: 872; addr: 0x106f1a460; uid: "VAD [vdef] AggDev 52"; virt strms: { }; phys devs: { [ id: 292; addr: 0x104b0fdb0; uid: "Speaker"; streams: { i/294/0x104b11cd0, o/293/0x104b12790 } ] } ] ]: 0.750000.
default 11:36:57.108123 -0700 mediaserverd OutputVolumeControl_HAL_Common.cpp:662:CommitVolume: Setting Volume = -14.500000 dB, Final HW Volume = 0.000000 dB, Final SW Volume = -14.500000 dB, External Volume Handler: No
default 11:36:57.109008 -0700 mediaserverd OutputVolumeControl_HAL_Common.cpp:663:CommitVolume: PhysicalDevice UID = "Speaker"
default 11:36:57.109721 -0700 mediaserverd OutputVolumeControl_HAL_Common.cpp:664:CommitVolume: Scope = 1869968496 ("outp")
default 11:36:57.110704 -0700 mediaserverd OutputVolumeControl_HAL_Common.cpp:665:CommitVolume: Element = 0 ("0")
default 11:36:57.112062 -0700 mediaserverd OutputVolumeControl_HAL_Common.cpp:698:CommitVolume: SW Volume: 0.750000 scalar
default 11:36:57.114393 -0700 mediaserverd VirtualAudio_Device.cpp:2066:SetPropertyData: Client request to set nominal sample rate to 44100.000000 on VAD 354.
default 11:36:57.116038 -0700 assertiond [Runner:14591] Attempting to acquire assertion for Runner:14591: <BKProcessAssertion: 0x101349110; "CMSession.14591."com.monkela.audioRecordSample"."MediaPlayback".isPlayingProcessAssertion" (audio:inf); id:…C74721DE1F95>
default 11:36:57.116572 -0700 assertiond [Runner:14591] Add assertion: <BKProcessAssertion: 0x101349110; id: 13077-914DDDE2-35CE-4420-85ED-C74721DE1F95; name: CMSession.14591."com.monkela.audioRecordSample"."MediaPlayback".isPlayingProcessAssertion; state: active; reason: audio; duration: infs> {
owner = <BSProcessHandle: 0x101009be0; mediaserverd:13077; valid: YES>;
flags = preventSuspend, preventThrottleDownCPU, preventIdleSleep, preventSuspendOnSleep;
}
When recording is working:
default 11:39:19.865022 -0700 mediaserverd 2863: { "action":"activate", "session":{"ID":"0x3315826","PID":14609,"name":"Runner"}, "details":"entry" }
default 11:39:19.880637 -0700 mediaserverd CAReportingClient.mm:328:-[CAReportingClient sendMessage:category:type:reporters:]: message {
"active devices" = "[ { vdef, [ ], [ pspk ( 0 ) ] }, { vspd, [ pmbi ( 0 ) ], [ ] }, { vcal, [ pdln ( 0 ) ], [ puln ( 0 ) ] } ]";
category = csav;
"going_active" = 1;
mode = imdf;
"staying_active" = 0;
}: (
857014546
)
The output when recording is broken suggests that my attempt to start recording actually starts playing something (i.e. invoking the wrong library).
I tracked this down and figured out how to make the libraries work together by modifying the stereo package. It turns out the stereo package was activating a playback audio session in application didFinishLaunchingWithOptions. Essentially these lines:
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayback error:&error];
[session setActive:YES error:&error];
I forked the stereo package and changed the code to activate the playback session only when it is actually needed. Magically my record function started working.
I'm not sure why it ever worked in the simulator. Somehow the simulator must be able to have both a playback and recording session going simultaneously.
UPDATE: The author of the stereo package accepted my pull request so as long as you have version 1.0.1 of the package, you should be able to avoid this interference issue.
The following bit of code works fine in my iPhone simulator. I'm tried with IOS 5.1 using Cordova 1.6 and also tried with 1.7. My external hosts entry is configured to 127.0.0.1
This is the code:
function uploadPhoto(imageElement){
var options = new FileUploadOptions();
var options = new FileUploadOptions();
options.fileKey="file";
options.mimeType="image/jpeg";
options.fileName="carimage.jpg";
options.chunkedMode = true;
var params = new Object();
params.value1 = "Car";
params.value2 = "Used";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
console.log("Upload Photo");
ft.upload(
document.getElementById(imageElement).src,
"http://127.0.0.1:8080/claim/image",
win,
fail,
options,
true);
console.log("Done Uploading");
}
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
The simulator output in Xcode is:
2012-05-09 12:45:09.390 motorazzi[24964:13403] Multi-tasking -> Device: YES, App: YES
2012-05-09 12:48:28.421 motorazzi[24964:13403] [INFO] Upload Photo
2012-05-09 12:48:28.484 motorazzi[24964:13403] [INFO] Done Uploading
2012-05-09 12:48:40.662 motorazzi[24964:13403] [INFO] Code = 200
2012-05-09 12:48:40.662 motorazzi[24964:13403] [INFO] Response =
2012-05-09 12:48:40.663 motorazzi[24964:13403] [INFO] Sent = 1358
Which is fine, but using the device from Xcode, I get:
2012-05-09 12:51:40.537 motorazzi[885:707] Multi-tasking -> Device: YES, App: YES
2012-05-09 12:51:56.554 motorazzi[885:707] [INFO] Upload Photo
2012-05-09 12:51:56.654 motorazzi[885:707] [INFO] Done Uploading
2012-05-09 12:51:56.748 motorazzi[885:707] File Transfer Error: Could not connect to the server.
2012-05-09 12:51:56.798 motorazzi[885:707] [INFO] An error has occurred: Code = 3
2012-05-09 12:51:56.803 motorazzi[885:707] [INFO] upload error source http://127.0.0.1:8080/claim/image
2012-05-09 12:51:56.813 motorazzi[885:707] [INFO] upload error target file:///var/mobile/Applications/699481A7-C598-43BA-BDCA-962DEF925EE5/tmp/photo_020.jpg
On my server log I can see that the device is not connecting at all. Is there anything that I may be doing wrong, or should be checking?
When you are running on the device the IP address 127.0.0.1 or "localhost" is the device itself. That is why you are not hitting your server. You will have to put in the host name or IP address of the server that is hosting your upload script.
Also, make sure you whitelist the server in your plist or it will get rejected.